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 #ifdef _MSC_VER
00035 # pragma warning (push, 3)
00036 # pragma warning(disable:4706) // assignment within conditional expression
00037 #endif
00038
00039 #include <log4cpp/Portability.hh>
00040 #include <log4cpp/Priority.hh>
00041
00042 namespace LOG4CPP_NS
00043 {
00044 class Category;
00045 class Appender;
00046 }
00047
00048 #include <stdio.h>
00049 #include <Base/GCBase.h>
00050 #include <Log/LogDll.h>
00051
00052 namespace GENICAM_NAMESPACE
00053 {
00054
00059 class LOG_DECL CLog
00060 {
00061 public:
00062
00064 static LOG4CPP_NS::Category& GetRootLogger( void );
00065
00067 static LOG4CPP_NS::Category& GetLogger( const gcstring &LoggerName );
00068 static LOG4CPP_NS::Category& GetLogger( const char LoggerName[] );
00069
00071 static bool Exists( const gcstring &LoggerName );
00072 static bool Exists( const char LoggerName[] );
00073
00075 static void PushNDC( const gcstring &ContextName );
00076 static void PushNDC( const char ContextName[] );
00077
00079 static void PopNDC( void );
00080
00082 static void Initialize( void );
00083
00085 static void ShutDown( void );
00086
00088 static void ConfigureDefault();
00089
00091 static bool ConfigureFromFile( const gcstring &FileName );
00092 static bool ConfigureFromFile( const char FileName[] );
00093
00095 static bool ConfigureFromEnvironment( void );
00096
00098 static bool ConfigureFromString( const gcstring &ConfigData );
00099 static bool ConfigureFromString( const char ConfigData[] );
00100
00102 static void RemoveAllAppenders(void);
00103
00105 static LOG4CPP_NS::Appender *CreateFileAppender( const gcstring &aName, const gcstring &aPath, bool aAppend = false, const gcstring &aPattern = "" );
00106
00108 static void AddAppender( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Appender *aAppender );
00109
00110 static void RemoveAppender( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Appender *aAppender );
00111
00112
00114 static void SetPriorityInfo( LOG4CPP_NS::Category *aCategory );
00115 static void SetPriorityError( LOG4CPP_NS::Category *aCategory );
00116
00118 static bool IsInfoEnabled( LOG4CPP_NS::Category *aCategory );
00119 static bool IsWarnEnabled( LOG4CPP_NS::Category *aCategory );
00120 static bool IsDebugEnabled( LOG4CPP_NS::Category *aCategory );
00121
00123 static void LogPush( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, ... );
00124 static void LogPop( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, ... );
00125 static void Log( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, ... );
00126 static void LogVA( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, va_list arg );
00127
00128 private:
00130 static void MakeSureLoggerHasBeenFound( void );
00131
00133 static int g_RefCount;
00134
00136 static const void *g_pLog4cpp;
00137
00139 #if defined (_WIN32)
00140 typedef HMODULE lib_handle_t;
00141 #else
00142 typedef void * lib_handle_t;
00143 #endif
00144
00146 static lib_handle_t g_pLibHandle;
00147
00149 static lib_handle_t OpenLibrary( const gcstring Name );
00150
00152 static void *FindSymbol( lib_handle_t Handle, const gcstring Name );
00153
00155 static bool g_HasFoundLogger;
00156
00157 };
00158
00159 }
00160
00161
00162 #define GCLOGINFO( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::INFO, ##__VA_ARGS__ ); }
00163 #define GCLOGINFOPUSH( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::LogPush( cat, LOG4CPP_NS::Priority::INFO, ##__VA_ARGS__ ); }
00164 #define GCLOGINFOPOP( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::LogPop( cat, LOG4CPP_NS::Priority::INFO, ##__VA_ARGS__ ); }
00165 #define GCLOGWARN( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::WARN, ##__VA_ARGS__ ); }
00166 #define GCLOGERROR( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::ERROR, ##__VA_ARGS__ ); }
00167 #define GCLOGDEBUG( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::DEBUG, ##__VA_ARGS__ ); }
00168
00169 #endif // LOG_CLOG_H_