CLog.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // (c) 2006 by Basler Vision Technologies
3 // Section: Vision Components
4 // Project: GenApi
5 // Author: Fritz Dierks
6 // $Header$
7 //
8 // License: This file is published under the license of the EMVA GenICam Standard Group.
9 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
10 // If for some reason you are missing this file please contact the EMVA or visit the website
11 // (http://www.genicam.org) for a full copy.
12 //
13 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
14 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
17 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 // POSSIBILITY OF SUCH DAMAGE.
24 //-----------------------------------------------------------------------------
31 #ifndef LOG_CLOG_H_
32 #define LOG_CLOG_H_
33 
34 #ifdef _MSC_VER
35 # pragma warning (push, 3)
36 # pragma warning(disable:4706) // assignment within conditional expression
37 #endif
38 
39 #include <log4cpp/Portability.hh>
40 #include <log4cpp/Priority.hh>
41 
42 namespace LOG4CPP_NS
43 {
44  class Category;
45  class Appender;
46 }
47 
48 #include <stdio.h>
49 #include <Base/GCBase.h>
50 #include <Log/LogDll.h>
51 
52 namespace GENICAM_NAMESPACE
53 {
54 
59  class LOG_DECL CLog
60  {
61  public:
62 
64  static LOG4CPP_NS::Category& GetRootLogger( void );
65 
67  static LOG4CPP_NS::Category& GetLogger( const gcstring &LoggerName );
68  static LOG4CPP_NS::Category& GetLogger( const char LoggerName[] );
69 
71  static bool Exists( const gcstring &LoggerName );
72  static bool Exists( const char LoggerName[] );
73 
75  static void PushNDC( const gcstring &ContextName );
76  static void PushNDC( const char ContextName[] );
77 
79  static void PopNDC( void );
80 
82  static void Initialize( void );
83 
85  static void ShutDown( void );
86 
88  static void ConfigureDefault();
89 
91  static bool ConfigureFromFile( const gcstring &FileName );
92  static bool ConfigureFromFile( const char FileName[] );
93 
95  static bool ConfigureFromEnvironment( void );
96 
98  static bool ConfigureFromString( const gcstring &ConfigData );
99  static bool ConfigureFromString( const char ConfigData[] );
100 
102  static void RemoveAllAppenders(void);
103 
105  static LOG4CPP_NS::Appender *CreateFileAppender( const gcstring &aName, const gcstring &aPath, bool aAppend = false, const gcstring &aPattern = "" );
106 
108  static void AddAppender( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Appender *aAppender );
109 
110  static void RemoveAppender( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Appender *aAppender );
111 
112 
114  static void SetPriorityInfo( LOG4CPP_NS::Category *aCategory );
115  static void SetPriorityError( LOG4CPP_NS::Category *aCategory );
116 
118  static bool IsInfoEnabled( LOG4CPP_NS::Category *aCategory );
119  static bool IsWarnEnabled( LOG4CPP_NS::Category *aCategory );
120  static bool IsDebugEnabled( LOG4CPP_NS::Category *aCategory );
121 
123  static void LogPush( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, ... );
124  static void LogPop( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, ... );
125  static void Log( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, ... );
126  static void LogVA( LOG4CPP_NS::Category *aCategory, LOG4CPP_NS::Priority::Value aPriority, const char *aStringFormat, va_list arg );
127 
128  private:
130  static void MakeSureLoggerHasBeenFound( void );
131 
133  static int g_RefCount;
134 
136  static const void *g_pLog4cpp;
137 
139 #if defined (_WIN32)
140  typedef HMODULE lib_handle_t;
141 #else
142  typedef void * lib_handle_t;
143 #endif
144 
146  static lib_handle_t g_pLibHandle;
147 
149  static lib_handle_t OpenLibrary( const gcstring Name );
150 
152  static void *FindSymbol( lib_handle_t Handle, const gcstring Name );
153 
155  static bool g_HasFoundLogger;
156 
157  };
158 
159 }
160 
161 // Logging macros (can be replaced by real functions for compilers not supporting it?)
162 #define GCLOGINFO( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::INFO, ##__VA_ARGS__ ); }
163 #define GCLOGINFOPUSH( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::LogPush( cat, LOG4CPP_NS::Priority::INFO, ##__VA_ARGS__ ); }
164 #define GCLOGINFOPOP( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::LogPop( cat, LOG4CPP_NS::Priority::INFO, ##__VA_ARGS__ ); }
165 #define GCLOGWARN( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::WARN, ##__VA_ARGS__ ); }
166 #define GCLOGERROR( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::ERROR, ##__VA_ARGS__ ); }
167 #define GCLOGDEBUG( cat, ... ) if(GENICAM_NAMESPACE::CLog::Exists("")) { GENICAM_NAMESPACE::CLog::Log( cat, LOG4CPP_NS::Priority::DEBUG, ##__VA_ARGS__ ); }
168 
169 #endif // LOG_CLOG_H_
void * lib_handle_t
A type corresponds to a library handle which can be platform specific.
Definition: CLog.h:142
static lib_handle_t g_pLibHandle
A handle to an associated logger library.
Definition: CLog.h:146
#define LOG_DECL
Definition: LogDll.h:48
static bool g_HasFoundLogger
A truth value of a proposition "Has found log4cpp.".
Definition: CLog.h:155
LOG4CPP_NS_BEGIN class LOG4CPP_EXPORT Category
Common GenICam base include file.
static const void * g_pLog4cpp
A wrapper which bridges log4cpp and this class.
Definition: CLog.h:136
declspec&#39;s to be used for Log Windows dll
This is the central class in the log4j package.
Definition: Category.hh:34
A string class which is a clone of std::string.
Definition: GCString.h:52
static int g_RefCount
Reference counter for Initialize/Shutdown.
Definition: CLog.h:133
Implement this interface for your own strategies for printing log statements.
Definition: Appender.hh:33
Helper class encapsulating log4cpp.
Definition: CLog.h:59


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 19:10:53