21 #include <winpr/config.h>
23 #include "SyslogAppender.h"
28 WLOG_APPENDER_COMMON();
31 static int getSyslogLevel(DWORD level)
52 static BOOL WLog_SyslogAppender_Open(wLog* log, wLogAppender* appender)
54 if (!log || !appender)
60 static BOOL WLog_SyslogAppender_Close(wLog* log, wLogAppender* appender)
62 if (!log || !appender)
68 static BOOL WLog_SyslogAppender_WriteMessage(wLog* log, wLogAppender* appender,
73 if (!log || !appender || !message)
76 syslogLevel = getSyslogLevel(message->Level);
78 syslog(syslogLevel,
"%s", message->TextString);
83 static BOOL WLog_SyslogAppender_WriteDataMessage(wLog* log, wLogAppender* appender,
88 if (!log || !appender || !message)
91 syslogLevel = getSyslogLevel(message->Level);
93 syslog(syslogLevel,
"skipped data message of %" PRIuz
" bytes", message->Length);
98 static BOOL WLog_SyslogAppender_WriteImageMessage(wLog* log, wLogAppender* appender,
103 if (!log || !appender || !message)
106 syslogLevel = getSyslogLevel(message->Level);
107 if (syslogLevel >= 0)
108 syslog(syslogLevel,
"skipped image (%" PRIuz
"x%" PRIuz
"x%" PRIuz
")", message->ImageWidth,
109 message->ImageHeight, message->ImageBpp);
114 static void WLog_SyslogAppender_Free(wLogAppender* appender)
119 wLogAppender* WLog_SyslogAppender_New(wLog* log)
121 wLogSyslogAppender* appender = NULL;
123 appender = (wLogSyslogAppender*)calloc(1,
sizeof(wLogSyslogAppender));
127 appender->Type = WLOG_APPENDER_SYSLOG;
129 appender->Open = WLog_SyslogAppender_Open;
130 appender->Close = WLog_SyslogAppender_Close;
131 appender->WriteMessage = WLog_SyslogAppender_WriteMessage;
132 appender->WriteDataMessage = WLog_SyslogAppender_WriteDataMessage;
133 appender->WriteImageMessage = WLog_SyslogAppender_WriteImageMessage;
134 appender->Free = WLog_SyslogAppender_Free;
136 return (wLogAppender*)appender;