Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031 #ifndef LOG_CLOG_H_
00032 #define LOG_CLOG_H_
00033
00034 #pragma warning (push, 3)
00035 #pragma warning(disable:4706) // assignment within conditional expression
00036
00037 #include <log4cpp/Portability.hh>
00038 #include <log4cpp/Priority.hh>
00039
00040 namespace LOG4CPP_NS
00041 {
00042 class Category;
00043 class Appender;
00044 }
00045
00046 #include <stdio.h>
00047 #include <Base/GCBase.h>
00048 #include <Log/LogDll.h>
00049
00050 namespace GENICAM_NAMESPACE
00051 {
00052
00057 class LOG_DECL CLog
00058 {
00059 public:
00060
00062 static LOG4CPP_NS::Category& GetRootLogger( void );
00063
00065 static LOG4CPP_NS::Category& GetLogger( const gcstring &LoggerName );
00066 static LOG4CPP_NS::Category& GetLogger( const char LoggerName[] );
00067
00069 static bool Exists( const gcstring &LoggerName );
00070 static bool Exists( const char LoggerName[] );
00071
00073 static void PushNDC( const gcstring &ContextName );
00074 static void PushNDC( const char ContextName[] );
00075
00077 static void PopNDC( void );
00078
00080 static void Initialize( void );
00081
00083 static void ShutDown( void );
00084
00086 static void ConfigureDefault();
00087
00089 static bool ConfigureFromFile( const gcstring &FileName );
00090 static bool ConfigureFromFile( const char FileName[] );
00091
00093 static bool ConfigureFromEnvironment( void );
00094
00096 static bool ConfigureFromString( const gcstring &ConfigData );
00097 static bool ConfigureFromString( const char ConfigData[] );
00098
00100 static void RemoveAllAppenders(void);
00101
00103 static LOG4CPP_NS::Appender *CreateFileAppender( const gcstring &aName, const gcstring &aPath, bool aAppend = false, const gcstring &aPattern = "" );
00104
00106 static void AddAppender( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Appender *aAppender );
00107
00108 static void RemoveAppender( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Appender *aAppender );
00109
00110
00112 static void SetPriorityInfo( LOG4CPP_NS::Category *aCategory );
00113 static void SetPriorityError( LOG4CPP_NS::Category *aCategory );
00114
00116 static bool IsInfoEnabled( LOG4CPP_NS::Category *aCategory );
00117 static bool IsWarnEnabled( LOG4CPP_NS::Category *aCategory );
00118 static bool IsDebugEnabled( LOG4CPP_NS::Category *aCategory );
00119
00121 static void LogPush( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, ... );
00122 static void LogPop( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, ... );
00123 static void Log( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, ... );
00124 static void LogVA( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, va_list arg );
00125
00126 private:
00128 static void MakeSureLoggerHasBeenFound( void );
00129
00131 static int g_RefCount;
00132
00134 static const void *g_pLog4cpp;
00135
00137 #if defined (_WIN32)
00138 typedef HMODULE lib_handle_t;
00139 #else
00140 typedef void * lib_handle_t;
00141 #endif
00142
00144 static lib_handle_t g_pLibHandle;
00145
00147 static lib_handle_t OpenLibrary( const gcstring Name );
00148
00150 static void *FindSymbol( lib_handle_t Handle, const gcstring Name );
00151
00153 static bool g_HasFoundLogger;
00154
00155 };
00156
00157 }
00158
00159
00160 #define GCLOGINFO( cat, ... ) if(cat != NULL) GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::INFO, ##__VA_ARGS__ )
00161 #define GCLOGINFOPUSH( cat, ... ) if(cat != NULL) GENICAM_NAMESPACE::CLog::LogPush( cat, LOG4CPP_NS::Priority::INFO, ##__VA_ARGS__ )
00162 #define GCLOGINFOPOP( cat, ... ) if(cat != NULL) GENICAM_NAMESPACE::CLog::LogPop( cat, LOG4CPP_NS::Priority::INFO, ##__VA_ARGS__ )
00163 #define GCLOGWARN( cat, ... ) if(cat != NULL) GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::WARN, ##__VA_ARGS__ )
00164 #define GCLOGERROR( cat, ... ) if(cat != NULL) GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::ERROR, ##__VA_ARGS__ )
00165 #define GCLOGDEBUG( cat, ... ) if(cat != NULL) GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::DEBUG, ##__VA_ARGS__ )
00166
00167
00168 #endif // LOG_CLOG_H_