forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
Logger.h
Go to the documentation of this file.
1 
9 #ifndef LOGGER_H
10 #define LOGGER_H
11 
12 #include <pthread.h>
13 #include "Packet.h"
14 #include "CtlPkt.h"
15 
16 namespace forest {
17 
18 
23 class Logger {
24 public:
25  Logger();
26 
27  void setLevel(int);
28 
35  void log(const string& s, int severity) {
36  if (severity >= level) logit(s,severity);
37  };
38  void log(const string& s, int severity, Packet& p) {
39  if (severity >= level) logit(s,severity,p);
40  };
41  void log(const string& s, int severity, CtlPkt& cp) {
42  if (severity >= level) logit(s,severity,cp);
43  };
44 
45 private:
46  int level;
47  pthread_mutex_t myLock;
48 
50  char* tag[4];
51 
52  // helper method
53  void logit(const string& s, int severity);
54  void logit(const string& s, int severity, Packet& p);
55  void logit(const string& s, int severity, CtlPkt& cp);
56 };
57 
58 } // ends namespace
59 
60 
61 #endif