SyslogTarget.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Utils_Logger_SyslogTarget_
18 #define HH_SENF_Utils_Logger_SyslogTarget_ 1
19 
20 // Custom includes
21 #include <syslog.h>
22 #include <boost/shared_ptr.hpp>
23 #include "Target.hh"
24 
25 //#include "SyslogTarget.mpp"
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 
28 namespace senf {
29 
30  namespace console { class DirectoryNode; }
31 
32 namespace log {
33 
69  : public Target
70  {
71  public:
72  //-////////////////////////////////////////////////////////////////////////
74  //\{
75 
76  explicit SyslogTarget(int facility = LOG_USER);
77 
78  //\}
79  //-////////////////////////////////////////////////////////////////////////
80 
81  private:
82  void v_write(time_type timestamp, std::string const & stream,
83  std::string const & area, unsigned level,
84  std::string const & message);
85 
86  int facility_;
87 
88  public:
89  static int const LEVELMAP[8];
90 
91  enum LogFacility {
92  AUTHPRIV = LOG_AUTHPRIV,
93  CRON = LOG_CRON,
94  DAEMON = LOG_DAEMON,
95  FTP = LOG_FTP,
96  KERN = LOG_KERN,
97  LOCAL0 = LOG_LOCAL0,
98  LOCAL1 = LOG_LOCAL1,
99  LOCAL2 = LOG_LOCAL2,
100  LOCAL3 = LOG_LOCAL3,
101  LOCAL4 = LOG_LOCAL4,
102  LOCAL5 = LOG_LOCAL5,
103  LOCAL6 = LOG_LOCAL6,
104  LOCAL7 = LOG_LOCAL7,
105  LPR = LOG_LPR,
106  MAIL = LOG_MAIL,
107  NEWS = LOG_NEWS,
108  SYSLOG = LOG_SYSLOG,
109  USER = LOG_USER,
110  UUCP = LOG_UUCP
111  };
112 
113  private:
114  struct RegisterConsole {
115  RegisterConsole();
116  static boost::shared_ptr<console::DirectoryNode> create(
117  LogFacility facility);
118  static RegisterConsole instance;
119  };
120  };
121 
122 }}
123 
124 //-/////////////////////////////////////////////////////////////////////////////////////////////////
125 #include "SyslogTarget.cci"
126 //#include "SyslogTarget.ct"
127 //#include "SyslogTarget.cti"
128 #endif
129 
130 
131 // Local Variables:
132 // mode: c++
133 // fill-column: 100
134 // comment-column: 40
135 // c-file-style: "senf"
136 // indent-tabs-mode: nil
137 // ispell-local-dictionary: "american"
138 // compile-command: "scons -u test"
139 // End:
Log target writing to the syslog.
Definition: SyslogTarget.hh:68
config::time_type time_type
Definition: TimeSource.hh:31
Logging target base class.
Definition: Target.hh:133
Target public header.