log.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _LOG_H_
00023 #define _LOG_H_
00024
00025 #include <iostream>
00026 #include <queue>
00027 #include <string>
00028
00029 #include <dcl/event.h>
00030 #include <dcl/strutils.h>
00031 #include <dcl/thread.h>
00032
00033 namespace dbp {
00034
00036
00040 class log {
00041 public:
00043
00049 log(std::ostream &out = std::clog, int verbose = 0);
00051
00054 virtual ~log();
00056
00063 void operator()(int level, const std::string &message);
00064 private:
00065 int _verbose;
00066 bool is_terminated;
00067 std::ostream &_out;
00068
00069 typedef std::queue<std::string> log_buffer;
00070 log_buffer buf;
00071
00072 thread t;
00073
00074 mutex _mlock;
00075 event _event;
00076
00077 void logging(thread_int&);
00078 };
00079
00080 }
00081
00082 #endif