diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-12-03 11:06:46 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-12-03 11:06:46 +0000 |
commit | 83b91cb8940986b365d58b04fe633fe396ff5d6b (patch) | |
tree | 2fed11b7eb3e50170f2ef8556e216300a247db07 /syslogd.c | |
parent | f500fbf50508c9c82d343a8ef6196ca25447402c (diff) | |
download | rsyslog-83b91cb8940986b365d58b04fe633fe396ff5d6b.tar.gz rsyslog-83b91cb8940986b365d58b04fe633fe396ff5d6b.tar.bz2 rsyslog-83b91cb8940986b365d58b04fe633fe396ff5d6b.zip |
adding sur5r's postgres module - many thanks for providing it! There are a
number of patches necessary to core modules, because we need a new
formatting function (date-pgsql).
Diffstat (limited to 'syslogd.c')
-rw-r--r-- | syslogd.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -644,6 +644,7 @@ static uchar template_WallFmt[] = "\"\r\n\7Message from syslogd@%HOSTNAME% at %t static uchar template_StdFwdFmt[] = "\"<%PRI%>%TIMESTAMP% %HOSTNAME% %syslogtag%%msg%\""; static uchar template_StdUsrMsgFmt[] = "\" %syslogtag%%msg%\n\r\""; static uchar template_StdDBFmt[] = "\"insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values ('%msg%', %syslogfacility%, '%HOSTNAME%', %syslogpriority%, '%timereported:::date-mysql%', '%timegenerated:::date-mysql%', %iut%, '%syslogtag%')\",SQL"; +static uchar template_StdPgSQLFmt[] = "\"insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values ('%msg%', %syslogfacility%, '%HOSTNAME%', %syslogpriority%, '%timereported:::date-pgsql%', '%timegenerated:::date-pgsql%', %iut%, '%syslogtag%')\",STDSQL"; /* end template */ @@ -1440,6 +1441,19 @@ int formatTimestampToMySQL(struct syslogTime *ts, char* pDst, size_t iLenDst) } +int formatTimestampToPgSQL(struct syslogTime *ts, char *pDst, size_t iLenDst) +{ + /* see note in formatTimestampToMySQL, applies here as well */ + assert(ts != NULL); + assert(pDst != NULL); + + if (iLenDst < 21) /* we need 20 bytes + '\n' */ + return(0); + + return(snprintf(pDst, iLenDst, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d", + ts->year, ts->month, ts->day, ts->hour, ts->minute, ts->second)); +} + /** * Format a syslogTimestamp to a RFC3339 timestamp string (as * specified in syslog-protocol). @@ -6101,6 +6115,8 @@ static void mainThread() tplAddLine(" StdUsrMsgFmt", &pTmp); pTmp = template_StdDBFmt; tplLastStaticInit(tplAddLine(" StdDBFmt", &pTmp)); + pTmp = template_StdPgSQLFmt; + tplLastStaticInit(tplAddLine(" StdPgSQLFmt", &pTmp)); dbgprintf("Starting.\n"); init(); |