--- /dev/null
+#include <syslog.h>
+#include <postgres.h>
+#include <miscadmin.h>
+#include <libpq/libpq-be.h>
+#include <fmgr.h>
+
+PG_FUNCTION_INFO_V1(logmsg);
+Datum logmsg(PG_FUNCTION_ARGS) {
+ text* arg0;
+ char* msg;
+ int len;
+
+ arg0 = PG_GETARG_TEXT_P(0);
+ len = arg0->vl_len - VARHDRSZ;
+
+ msg = (char*) palloc(len+1);
+ memcpy(msg, arg0->vl_dat, len);
+ msg[len] = '\0';
+
+ openlog("postgres", LOG_PID, LOG_LOCAL6);
+ syslog(LOG_INFO, "[%s]: %s", GetUserNameFromId(GetUserId()), msg);
+ closelog();
+
+ pfree(msg);
+
+ /* not reached */
+ PG_RETURN_VOID();
+}