FreeRDP-WebConnect WebSockets gateway  1.0.0.167
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends Pages
logging.hpp
1 /* vim: set et ts=4 sw=4 cindent:
2  *
3  * FreeRDP-WebConnect,
4  * A gateway for seamless access to your RDP-Sessions in any HTML5-compliant browser.
5  *
6  * Copyright 2012 Fritz Elfert <wsgate@fritz-elfert.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 #ifndef _LOGGING_H_
21 #define _LOGGING_H_
22 
23 # include <ostream>
24 # include <string>
25 # include <bitset>
26 
27 namespace wsgate {
28 
36  class logger {
37  public:
38 
40  typedef enum {
41  AUTH,
42  AUTHPRIV,
43  CRON,
44  DAEMON,
45  FTP,
46  KERN,
47  LOCAL0,
48  LOCAL1,
49  LOCAL2,
50  LOCAL3,
51  LOCAL4,
52  LOCAL5,
53  LOCAL6,
54  LOCAL7,
55  LPR,
56  MAIL,
57  NEWS,
58  SYSLOG,
59  USER,
60  UUCP
61  } Facility;
62 
84  logger(const std::string & ident, const Facility facility = DAEMON, const std::string & mask = "11111111");
85 
89  logger(const logger &other);
90 
91  ~logger();
92 
96  logger & operator=(const logger &other);
97 
101  static void release();
102 
106  static void enable();
107 
111  static void disable();
112 
118  void setmask(std::bitset<8>mask);
119 
124  void setmaskByName(const std::string & names);
125 
131  void setfacility(Facility facility);
132 
138  void setfacilityByName(const std::string & facility);
139 
148  static std::ostream debug;
149 
157  static std::ostream info;
158 
166  static std::ostream notice;
167 
175  static std::ostream warn;
176 
184  static std::ostream err;
185 
193  static std::ostream crit;
194 
202  static std::ostream alert;
203 
211  static std::ostream emerg;
212 
213  private:
219  std::bitset<8> namesToBitset(std::string names);
220 
227  void init(Facility facility, std::bitset<8>mask);
228 
229  char *ident;
230 
231  std::bitset<8> mask;
232  };
233 
234 }
235 
236 #endif