From c4e5a130ee2f045d9361fae33c5f9c6ecef270b8 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 26 Mar 2016 09:49:45 -0400 Subject: [PATCH] don't break win32 --- Log.cpp | 10 ++++++++-- Log.h | 11 ++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Log.cpp b/Log.cpp index fbaac8c1..bb4f8231 100644 --- a/Log.cpp +++ b/Log.cpp @@ -10,7 +10,7 @@ static const char * g_LogLevelStr[eNumLogLevels] = "info", // eLogInfo "debug" // eLogDebug }; - +#ifndef _WIN32 /** convert LogLevel enum to syslog priority level */ static int ToSyslogLevel(LogLevel lvl) { @@ -28,15 +28,17 @@ static int ToSyslogLevel(LogLevel lvl) return LOG_CRIT; } } - +#endif void LogMsg::Process() { +#ifndef _WIN32 if (log && log->SyslogEnabled()) { // only log to syslog syslog(ToSyslogLevel(level), "%s", s.str().c_str()); return; } +#endif auto stream = log ? log->GetLogStream () : nullptr; auto& output = stream ? *stream : std::cout; if (log) @@ -111,14 +113,18 @@ void Log::SetLogStream (std::shared_ptr logStream) void Log::StartSyslog(const std::string & ident, const int facility) { +#ifndef _WIN32 m_Ident = ident; openlog(m_Ident.c_str(), LOG_PID, facility); +#endif } void Log::StopSyslog() { +#ifndef _WIN32 closelog(); m_Ident.clear(); +#endif } bool Log::SyslogEnabled() diff --git a/Log.h b/Log.h index 701c450d..76866590 100644 --- a/Log.h +++ b/Log.h @@ -8,9 +8,12 @@ #include #include #include -#include #include "Queue.h" +#ifndef _WIN32 +#include +#endif + enum LogLevel { eLogError = 0, @@ -48,7 +51,7 @@ class Log: public i2p::util::MsgQueue LogLevel GetLogLevel () { return m_MinLevel; }; const std::string& GetFullFilePath () const { return m_FullFilePath; }; /** start logging to syslog */ - void StartSyslog(const std::string & ident, const int facility = LOG_USER); + void StartSyslog(const std::string & ident, const int facility); /** stop logging to syslog */ void StopSyslog(); /** are we logging to syslog right now? */ @@ -126,7 +129,9 @@ inline bool IsLogToFile () inline void StartSyslog() { StartLog(""); - g_Log->StartSyslog("i2pd"); +#ifndef _WIN32 + g_Log->StartSyslog("i2pd", LOG_USER); +#endif } inline void StopSyslog()