00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __LOGGING_H__
00032 #define __LOGGING_H__
00033
00034 #include "global.h"
00035
00036 #define MAX_LOG_STR_LEN 900
00037 #define LOG_BUFFER_SIZE 20
00038
00039
00040 #define LOG_ERROR 0
00041
00042 #define LOG_NETFLOWLOG 252
00043
00044 #define LOG_EVENT 253
00045
00046 #define LOG_INFORM 254
00047
00048 #define LOG_LOGGING 255
00049
00050
00051 namespace tacpp {
00052
00058 class LogData {
00061 pthread_mutex_t mutex_;
00064 void lock();
00067 void unlock();
00070 int level;
00073 string str_;
00076 bool is_written_;
00077 public:
00080 LogData(int,string);
00083 int get_level();
00086 string get_string();
00089 ~LogData();
00092 bool isWritten();
00095 void setWritten(bool);
00096 };
00097
00103 class LogList {
00106 pthread_mutex_t mutex_;
00109 void lock();
00112 void unlock();
00115 int num_;
00118 list<LogData*> logs;
00119 public:
00122 int getNum();
00125 LogList(int);
00128 ~LogList();
00131 void add(int,string);
00134 string del(int);
00137 LogData *getEntry();
00140 int size();
00141 };
00142
00148 class Logging_end {
00149 public:
00150 };
00151
00157 class Logging_set {
00158 public:
00161 int level;
00164 Logging_set(int a) {
00165 level = a;
00166 }
00169 void operator =(Logging_set x) {
00170 level = x.level;
00171 }
00172 };
00173
00179 class Logging {
00182 list<LogList*> tacpp_loglist;
00185 pthread_mutex_t Mutex_;
00188 pthread_mutex_t Mutex2_;
00191 void lock2();
00194 void unlock2();
00195 public:
00198 void lock();
00201 void unlock();
00204 Logging();
00207 ~Logging();
00210 LogList *getl(int);
00213 int add();
00216 void del(int);
00219 void out_msg(int, string);
00222 void out_netflow(string);
00225 void out_logging(string);
00228 void log(int, char *fmt,...);
00231 void clear();
00234 int size();
00237 string sbuf;
00240 int log2_level;
00243 bool present;
00246 Logging_end Logging_end_endlog();
00249 Logging_set Logging_set_setlog(int);
00252 Logging& operator <<(const char*);
00255 Logging& operator <<(const int);
00258 Logging& operator <<(const unsigned int);
00261 Logging& operator <<(const string);
00264 Logging& operator <<(ipaddr);
00267 Logging& operator <<(const float);
00270 Logging& operator <<(const double);
00273 Logging& operator <<(const bool);
00276 Logging& operator <<(Logging_end);
00279 Logging& operator <<(Logging_set);
00280 };
00281
00282 };
00283
00284 #endif //__LOGGING_H__