|
|
@ -10,7 +10,7 @@ static const char * g_LogLevelStr[eNumLogLevels] = |
|
|
|
"info", // eLogInfo
|
|
|
|
"info", // eLogInfo
|
|
|
|
"debug" // eLogDebug
|
|
|
|
"debug" // eLogDebug
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
#ifndef _WIN32 |
|
|
|
/** convert LogLevel enum to syslog priority level */ |
|
|
|
/** convert LogLevel enum to syslog priority level */ |
|
|
|
static int ToSyslogLevel(LogLevel lvl) |
|
|
|
static int ToSyslogLevel(LogLevel lvl) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -28,15 +28,17 @@ static int ToSyslogLevel(LogLevel lvl) |
|
|
|
return LOG_CRIT; |
|
|
|
return LOG_CRIT; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
void LogMsg::Process() |
|
|
|
void LogMsg::Process() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifndef _WIN32 |
|
|
|
if (log && log->SyslogEnabled()) { |
|
|
|
if (log && log->SyslogEnabled()) { |
|
|
|
// only log to syslog
|
|
|
|
// only log to syslog
|
|
|
|
syslog(ToSyslogLevel(level), "%s", s.str().c_str()); |
|
|
|
syslog(ToSyslogLevel(level), "%s", s.str().c_str()); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
auto stream = log ? log->GetLogStream () : nullptr; |
|
|
|
auto stream = log ? log->GetLogStream () : nullptr; |
|
|
|
auto& output = stream ? *stream : std::cout; |
|
|
|
auto& output = stream ? *stream : std::cout; |
|
|
|
if (log) |
|
|
|
if (log) |
|
|
@ -111,14 +113,18 @@ void Log::SetLogStream (std::shared_ptr<std::ostream> logStream) |
|
|
|
|
|
|
|
|
|
|
|
void Log::StartSyslog(const std::string & ident, const int facility) |
|
|
|
void Log::StartSyslog(const std::string & ident, const int facility) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifndef _WIN32 |
|
|
|
m_Ident = ident; |
|
|
|
m_Ident = ident; |
|
|
|
openlog(m_Ident.c_str(), LOG_PID, facility); |
|
|
|
openlog(m_Ident.c_str(), LOG_PID, facility); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Log::StopSyslog() |
|
|
|
void Log::StopSyslog() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#ifndef _WIN32 |
|
|
|
closelog(); |
|
|
|
closelog(); |
|
|
|
m_Ident.clear(); |
|
|
|
m_Ident.clear(); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool Log::SyslogEnabled() |
|
|
|
bool Log::SyslogEnabled() |
|
|
|