Added error and debug logging
It is now possible to log errors and debug messages to the database. They both store up to 1000 messages.