wLogAppender* WLog_Appender_New(wLog* log, DWORD logAppenderType) { wLogAppender* appender = NULL; if (logAppenderType == WLOG_APPENDER_CONSOLE) { appender = (wLogAppender*) WLog_ConsoleAppender_New(log); } else if (logAppenderType == WLOG_APPENDER_FILE) { appender = (wLogAppender*) WLog_FileAppender_New(log); } else if (logAppenderType == WLOG_APPENDER_BINARY) { appender = (wLogAppender*) WLog_BinaryAppender_New(log); } if (!appender) appender = (wLogAppender*) WLog_ConsoleAppender_New(log); appender->Layout = WLog_Layout_New(log); InitializeCriticalSectionAndSpinCount(&appender->lock, 4000); return appender; }
wLogAppender* WLog_Appender_New(wLog* log, DWORD logAppenderType) { wLogAppender* appender; if (!log) return NULL; switch (logAppenderType) { case WLOG_APPENDER_CONSOLE: appender = WLog_ConsoleAppender_New(log); break; case WLOG_APPENDER_FILE: appender = WLog_FileAppender_New(log); break; case WLOG_APPENDER_BINARY: appender = WLog_BinaryAppender_New(log); break; case WLOG_APPENDER_CALLBACK: appender = WLog_CallbackAppender_New(log); break; #ifdef HAVE_SYSLOG_H case WLOG_APPENDER_SYSLOG: appender = WLog_SyslogAppender_New(log); break; #endif #ifdef HAVE_JOURNALD_H case WLOG_APPENDER_JOURNALD: appender = WLog_JournaldAppender_New(log); break; #endif case WLOG_APPENDER_UDP: appender = (wLogAppender*) WLog_UdpAppender_New(log); break; default: fprintf(stderr, "%s: unknown handler type %d\n", __FUNCTION__, logAppenderType); appender = NULL; break; } if (!appender) appender = (wLogAppender*) WLog_ConsoleAppender_New(log); if (!appender) return NULL; if (!(appender->Layout = WLog_Layout_New(log))) { WLog_Appender_Free(log, appender); return NULL; } InitializeCriticalSectionAndSpinCount(&appender->lock, 4000); return appender; }