28 int decode( G::LogOutput::SyslogFacility facility )
30 if( facility == G::LogOutput::User )
return LOG_USER ;
31 if( facility == G::LogOutput::Daemon )
return LOG_DAEMON ;
32 if( facility == G::LogOutput::Mail )
return LOG_MAIL ;
33 if( facility == G::LogOutput::Cron )
return LOG_CRON ;
37 int decode( G::Log::Severity severity )
39 if( severity == G::Log::s_Warning )
return LOG_WARNING ;
40 if( severity == G::Log::s_Error )
return LOG_ERR ;
41 if( severity == G::Log::s_LogSummary )
return LOG_INFO ;
42 if( severity == G::Log::s_LogVerbose )
return LOG_INFO ;
45 int mode( G::LogOutput::SyslogFacility facility , G::Log::Severity severity )
47 return decode(facility) | decode(severity) ;
53 if( severity != G::Log::s_Debug && m_syslog )
55 ::syslog( mode(m_facility,severity) ,
"%s" , message.c_str() ) ;
57 std_err << message << std::endl ;
60 void G::LogOutput::init()
63 ::openlog(
nullptr , LOG_PID , decode(m_facility) ) ;
66 void G::LogOutput::cleanup()
72 void G::LogOutput::getLocalTime( time_t epoch_time ,
struct std::tm * broken_down_time_p )
74 localtime_r( &epoch_time , broken_down_time_p ) ;
bool syslog() const
Returns true if syslog output is enabled.
virtual void rawOutput(std::ostream &, G::Log::Severity, const std::string &)
Overridable.