X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FSyslogUDPTarget.hh;h=25bb8930c0657d9248206a1e7dbd4f4c7739b645;hb=c5ebf1fef99c27a3fdc02a70bff041ac881f4c32;hp=c3d8b152146b97841f0a745b1d2cce0a374560d9;hpb=07b8c0784c854893cd1a4ecb9aa051a625ebe17e;p=senf.git diff --git a/Utils/Logger/SyslogUDPTarget.hh b/Utils/Logger/SyslogUDPTarget.hh index c3d8b15..25bb893 100644 --- a/Utils/Logger/SyslogUDPTarget.hh +++ b/Utils/Logger/SyslogUDPTarget.hh @@ -86,6 +86,8 @@ namespace log { include the \c PRI part but skip the \c HEADER part (which includes the timestamp and hostname) for better performance. We add a space after the \c PRI to force the syslog daemon to skip the \c HEADER part. + + \ingroup targets */ class SyslogUDPTarget : public Target, private detail::LogFormat @@ -113,17 +115,65 @@ namespace log { using detail::LogFormat::timeFormat; using detail::LogFormat::tag; + bool syslog() const; ///< \c true, if using syslog format, \c false otherwise + /**< When syslog format is disabled, messages are not + formated as valid syslog messages but sent using plain + UDP. */ + void syslog(bool enabled=true); /// Set syslog format + private: + void init(); void v_write(time_type timestamp, std::string const & stream, std::string const & area, unsigned level, std::string const & message); + void consoleFormat(std::ostream & os); + int facility_; typedef senf::ClientSocketHandle< senf::MakeSocketPolicy< senf::DatagramFramingPolicy, senf::ConnectedCommunicationPolicy, senf::WriteablePolicy>::policy > Handle; Handle handle_; + bool syslogFormat_; + + public: + 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( + senf::INet4SocketAddress const & target, LogFacility facility = USER); + static boost::shared_ptr create( + senf::INet4Address const & target, LogFacility facility = USER); + static boost::shared_ptr create( + senf::INet6SocketAddress const & target, LogFacility facility = USER); + static boost::shared_ptr create( + senf::INet6Address const & target, LogFacility facility = USER); + static RegisterConsole instance; + }; }; }}