Logging messages to postgres database, thanks to @bbqduc