X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FSyslogTarget.hh;h=eeebbb93da9d9b7dc8072c414b49d45d1ae127d8;hb=f2f5d59e83863f3b513950173baee1b6da2aee3c;hp=70cf4e322e1965692463617eac10bc8ae7c9be3a;hpb=9a074ebd4b82022bfe686b40de8db80927def2b8;p=senf.git diff --git a/Utils/Logger/SyslogTarget.hh b/Utils/Logger/SyslogTarget.hh index 70cf4e3..eeebbb9 100644 --- a/Utils/Logger/SyslogTarget.hh +++ b/Utils/Logger/SyslogTarget.hh @@ -23,23 +23,34 @@ /** \file \brief SyslogTarget public header */ -#ifndef HH_SyslogTarget_ -#define HH_SyslogTarget_ 1 +#ifndef HH_SENF_Utils_Logger_SyslogTarget_ +#define HH_SENF_Utils_Logger_SyslogTarget_ 1 // Custom includes #include +#include #include "Target.hh" //#include "SyslogTarget.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { + + namespace console { class DirectoryNode; } + namespace log { /** \brief Log target writing to the syslog The SyslogTarget will send all log messages to the syslog at the given facility. + \code + senf::log::SyslogTarget syslog; + + // Route all messages to the syslog + syslog.route(); + \endcode + Valid facility values (taken from man 3 syslog): \par "" LOG_AUTHPRIV, LOG_CRON, LOG_DAEMON, LOG_FTP, @@ -50,6 +61,17 @@ namespace log { The default facility is LOG_USER. + The SENF log levels are mapped to syslog levels in the following way: + + + + + + + + +
senf::log::VERBOSE \c LOG_DEBUG
senf::log::NOTICE \c LOG_INFO
senf::log::MESSAGE \c LOG_NOTICE
senf::log::IMPORTANT \c LOG_WARNING
senf::log::CRITICAL \c LOG_CRIT
senf::log::FATAL \c LOG_EMERG
+ \ingroup targets */ class SyslogTarget @@ -71,7 +93,39 @@ namespace log { std::string const & message); int facility_; - static int const LEVELMAP_[8]; + + public: + static int const LEVELMAP[8]; + + enum LogFacility { + AUTHPRIV = LOG_AUTHPRIV, + CRON = LOG_CRON, + DAEMON = LOG_DAEMON, + FTP = LOG_FTP, + KERN = LOG_KERN, + LOCAL0 = LOG_LOCAL0, + LOCAL1 = LOG_LOCAL1, + LOCAL2 = LOG_LOCAL2, + LOCAL3 = LOG_LOCAL3, + LOCAL4 = LOG_LOCAL4, + LOCAL5 = LOG_LOCAL5, + LOCAL6 = LOG_LOCAL6, + LOCAL7 = LOG_LOCAL7, + LPR = LOG_LPR, + MAIL = LOG_MAIL, + NEWS = LOG_NEWS, + SYSLOG = LOG_SYSLOG, + USER = LOG_USER, + UUCP = LOG_UUCP + }; + + private: + struct RegisterConsole { + RegisterConsole(); + static boost::shared_ptr create( + LogFacility facility); + static RegisterConsole instance; + }; }; }}