diff --git a/src/lib/logging/Sink.cpp b/src/lib/logging/Sink.cpp index aee2e894e..1af90674e 100644 --- a/src/lib/logging/Sink.cpp +++ b/src/lib/logging/Sink.cpp @@ -13,9 +13,7 @@ #include #include -#ifdef WIN32 -#include -#else +#ifndef WIN32 #include #endif @@ -23,15 +21,10 @@ namespace bts { namespace log { -#ifdef WIN32 -HANDLE win_event_log; -#endif struct InitSysLog { InitSysLog() { -#ifdef WIN32 - win_event_log = RegisterEventSource(NULL,"spark"); -#else +#ifndef WIN32 openlog("spark",0,LOG_USER); #endif @@ -62,32 +55,12 @@ Sink console_sink() { } Sink syslog_sink() { - auto f = formatter(); #ifdef WIN32 - return [f] (LogMsg const &m) { - int win_level; - switch (m.level.ordinal) { - case 0: - win_level = EVENTLOG_SUCCESS; - break; - case 1: - win_level = EVENTLOG_INFORMATION_TYPE; - break; - case 2: - win_level = EVENTLOG_WARNING_TYPE; - break; - default: - win_level = EVENTLOG_ERROR_TYPE; - break; - - }; - auto str = f(m).c_str(); - ReportEvent(win_event_log,win_level,0,0,NULL,1,0,&str,0); - }; + return null_sink(); #else + auto f = formatter(); return [f] (LogMsg const &m) {syslog (LOG_INFO | LOG_USER,"%s",f(m).c_str ());}; #endif - } std::ifstream::pos_type filesize(std::string const&filename) @@ -121,6 +94,10 @@ Sink file_sink() { auto stream = new std::ofstream(path.string(),std::ofstream::app); return [f,stream] (LogMsg const &m) {*stream << f(m) << std::endl;}; } + +Sink null_sink() { + return [](const LogMsg&m) {}; +} }} diff --git a/src/lib/logging/Sink.h b/src/lib/logging/Sink.h index 28676dccf..c6491bd29 100644 --- a/src/lib/logging/Sink.h +++ b/src/lib/logging/Sink.h @@ -31,4 +31,5 @@ using Sink = std::function ; Sink syslog_sink(); Sink console_sink(); Sink file_sink(); +Sink null_sink(); }}