Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Logger.h
Go to the documentation of this file.
1 /*
2  * Dibbler - a portable DHCPv6
3  *
4  * authors: Tomasz Mrugalski <thomson@klub.com.pl>
5  * Marek Senderski <msend@o2.pl>
6  * changes: Michal Kowalczuk <michal@kowalczuk.eu>
7  *
8  * Released under GNU GPL v2 only licence
9  *
10  */
11 
12 #ifndef LOGGER_H
13 #define LOGGER_H
14 #include <iostream>
15 #include <string>
16 #include "DHCPConst.h"
17 #include <stdint.h>
18 
19 #define Log(X) logger :: log##X ()
20 #define LogEnd logger :: endl
21 
22 #define LOGMODE_DEFAULT LOGMODE_FULL
23 
24 namespace logger {
25 
26  enum Elogmode {
30  LOGMODE_SYSLOG, /* unix only */
31  LOGMODE_EVENTLOG /* windows only */
32  };
33 
34  std::ostream& logCont();
35  std::ostream& logEmerg();
36  std::ostream& logAlert();
37  std::ostream& logCrit();
38  std::ostream& logError();
39  std::ostream& logWarning();
40  std::ostream& logNotice();
41  std::ostream& logInfo();
42  std::ostream& logDebug();
43  std::ostream & endl (std::ostream & strum);
44 
45  void Initialize(const char * file);
46  void Terminate();
47  void setLogName(const std::string x);
48  void setLogLevel(int x);
49  void setLogMode(const std::string x);
50  void EchoOff();
51  void EchoOn();
52  void setColors(bool colors);
53  std::string getLogName();
54  int getLogLevel();
55 }
56 
57 std::string StateToString(EState state);
58 std::string StatusCodeToString(int status);
59 std::string MsgTypeToString(int msgType);
60 
61 // for debugging purposes
62 void PrintHex(const std::string& message, const uint8_t *buf, unsigned len);
63 
64 #endif
65