00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef LOG_H
00022 #define LOG_H
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include "config.h"
00026 #endif
00027
00028 #include <iostream>
00029 #include <cstdlib>
00030 #include <stdint.h>
00031 #include <sstream>
00032
00033 #include "mutex.h"
00034
00035 #include <memory>
00036
00037 using namespace std;
00038
00039 namespace openikev2 {
00040
00041 typedef class IkeSaController;
00042 typedef class Alarm;
00043 typedef class ChildSa;
00044 typedef class IkeSaExecuter;
00045 typedef class LogImpl;
00046
00051 class Log {
00052
00053
00054 public:
00056 enum LOG_TYPE{
00057 LOG_NONE = 0x0000,
00058 LOG_INFO = 0x0001,
00059 LOG_MESG = 0x0002,
00060 LOG_STAT = 0x0004,
00061 LOG_CRYP = 0x0008,
00062 LOG_THRD = 0x0010,
00063 LOG_ERRO = 0x0020,
00064 LOG_ALRM = 0x0040,
00065 LOG_DHCP = 0x0080,
00066 LOG_IPSC = 0x0100,
00067 LOG_HALF = 0x0200,
00068 LOG_POLI = 0x0400,
00069 LOG_EBUS = 0x0800,
00070 LOG_CONF = 0x1000,
00071 LOG_WARN = 0x2000,
00072 LOG_ALL = 0xFFFF,
00073 };
00074
00075
00076 protected:
00077 static auto_ptr<LogImpl> implementation;
00078 static auto_ptr<Mutex> log_mutex;
00080
00081 public:
00087 static string LOG_TYPE_STR( uint16_t type );
00088
00093 static void setImplementation( auto_ptr<LogImpl> implementation );
00094
00099 static void setLogMask( uint16_t log_mask );
00100
00105 static void showExtraInfo( bool extra );
00106
00114 static void writeMessage( string who, string message, uint16_t type, bool main_info );
00115
00123 static void writeLockedMessage( string who, string message, uint16_t type, bool main_info );
00124
00129 static void open( string file_name );
00130
00134 static void close();
00135
00139 static void acquire();
00140
00144 static void release();
00145
00153 static void writeMessage( IkeSaController& ike_sa_controller, string message, uint16_t type, bool main_info );
00154
00162 static void writeLockedMessage( IkeSaController& ike_sa_controller, string message, uint16_t type, bool main_info );
00163
00171 static void writeMessage( Alarm& alarm, string message, uint16_t type, bool main_info );
00172
00180 static void writeLockedMessage( Alarm& alarm, string message, uint16_t type, bool main_info );
00181
00189 static void writeMessage( ChildSa& childsa, string message, uint16_t type, bool main_info );
00190
00198 static void writeLockedMessage( ChildSa& childsa, string message, uint16_t type, bool main_info );
00199
00207 static void writeMessage( IkeSaExecuter& ike_sa_executer, string message, uint16_t type, bool main_info );
00208
00216 static void writeLockedMessage( IkeSaExecuter& command_executer, string message, uint16_t type, bool main_info );
00217 };
00218 }
00219
00220 #endif