X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FSyslogUDPTarget.hh;h=e6f35ffc1f381afa71781c4ff46745c788237e27;hb=8da6e83b001f0ae8383af7eb4b3e3a079178a777;hp=6b7e2693f01416f19036d8baebe9dea2bff38ec5;hpb=204c9c8a9df166f1c220bbd86e1c7a839382c73d;p=senf.git diff --git a/Utils/Logger/SyslogUDPTarget.hh b/Utils/Logger/SyslogUDPTarget.hh index 6b7e269..e6f35ff 100644 --- a/Utils/Logger/SyslogUDPTarget.hh +++ b/Utils/Logger/SyslogUDPTarget.hh @@ -28,6 +28,7 @@ // Custom includes #include "SyslogTarget.hh" +#include "LogFormat.hh" #include "../../Socket/Protocols/INet/INetAddressing.hh" #include "../../Socket/ClientSocketHandle.hh" #include "../../Socket/FramingPolicy.hh" @@ -85,9 +86,11 @@ 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 + : public Target, private detail::LogFormat { public: /////////////////////////////////////////////////////////////////////////// @@ -105,11 +108,12 @@ namespace log { ///@} /////////////////////////////////////////////////////////////////////////// - void showStream(bool flag = true); - void showLevel(bool flag = true); - void showArea(bool flag = true); - - void tag(std::string const & tag); + using detail::LogFormat::showTime; + using detail::LogFormat::showStream; + using detail::LogFormat::showLevel; + using detail::LogFormat::showArea; + using detail::LogFormat::timeFormat; + using detail::LogFormat::tag; private: void v_write(time_type timestamp, std::string const & stream, @@ -117,15 +121,49 @@ namespace log { std::string const & message); int facility_; - std::string tag_; typedef senf::ClientSocketHandle< senf::MakeSocketPolicy< senf::DatagramFramingPolicy, senf::ConnectedCommunicationPolicy, senf::WriteablePolicy>::policy > Handle; Handle handle_; - bool showStream_; - bool showLevel_; - bool showArea_; + + 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 void create(senf::INet4SocketAddress const & target, + LogFacility facility = USER); + static void create(senf::INet4Address const & target, + LogFacility facility = USER); + static void create(senf::INet6SocketAddress const & target, + LogFacility facility = USER); + static void create(senf::INet6Address const & target, + LogFacility facility = USER); + static RegisterConsole instance; + }; }; }}