moved statistics classes from NetEmu to SENF
[senf.git] / Utils / Logger / SyslogTarget.hh
index 70cf4e3..eeebbb9 100644 (file)
 /** \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 <syslog.h>
+#include <boost/shared_ptr.hpp>
 #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 <tt>man 3 syslog</tt>):
         \par "" 
            <tt>LOG_AUTHPRIV</tt>, <tt>LOG_CRON</tt>, <tt>LOG_DAEMON</tt>, <tt>LOG_FTP</tt>,
@@ -50,6 +61,17 @@ namespace log {
 
         The default facility is <tt>LOG_USER</tt>.
 
+        The SENF log levels are mapped to syslog levels in the following way:
+
+        <table class="senf fixedcolumn">
+        <tr><td>senf::log::VERBOSE</td>   <td>\c LOG_DEBUG</td></tr>
+        <tr><td>senf::log::NOTICE</td>    <td>\c LOG_INFO</td></tr>
+        <tr><td>senf::log::MESSAGE</td>   <td>\c LOG_NOTICE</td></tr>
+        <tr><td>senf::log::IMPORTANT</td> <td>\c LOG_WARNING</td></tr>
+        <tr><td>senf::log::CRITICAL</td>  <td>\c LOG_CRIT</td></tr>
+        <tr><td>senf::log::FATAL</td>     <td>\c LOG_EMERG</td></tr>
+        </table>
+
         \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<senf::console::DirectoryNode> create(
+                LogFacility facility);
+            static RegisterConsole instance;
+        };
     };
 
 }}