CLog.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3 (c) 2017 by STEMMER IMAGING GmbH
4 Project: Modular Logging
5 Author: Quang Nguyen
6 
7 License: This file is published under the license of the EMVA GenICam Standard Group.
8 A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
9 If for some reason you are missing this file please contact the EMVA or visit the website
10 (http://www.genicam.org) for a full copy.
11 
12 THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
13 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
16 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
19 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22 POSSIBILITY OF SUCH DAMAGE.
23 
24 ****************************************************************************/
25 
26 
27 
28 
29 #ifndef LOG_CLOG_H_
30 #define LOG_CLOG_H_
31 
32 #ifdef _MSC_VER
33 # pragma warning (push, 3)
34 # pragma warning(disable:4706) // assignment within conditional expression
35 #endif
36 //#pragma warning (push, 3)
37 //#pragma warning(disable:4706) // assignment within conditional expression
38 
39 #include <stdio.h>
40 #include <map>
41 #include <Log/LogDll.h>
42 
43 #include <Base/GCBase.h>
44 #include <Log/ILogger.h>
45 #include <Log/ILoggerFactory.h>
46 
47 
48 namespace GENICAM_NAMESPACE
49 {
54  class LOG_DECL CLog
55  {
56  public:
60  static bool Exist(const gcstring &LoggerName);
61  static bool Exist(const char* LoggerName);
62 
63 
66  static ILogger& GetLogger(const gcstring &LoggerName);
67  static ILogger& GetLogger(const char* LoggerName);
68 
69  static void PushIndent();
70  static void PopIndent();
71 
72  // No logger is being used
73  static void OmitLogger();
74 
75  // Will take ownership of the ILoggerFactory. ShutDown will delete that object
76  static void SetLoggerFactory(ILoggerFactory&);
77  static ILoggerFactory* GetLoggerFactory();
78 
80  static void ShutDown(void);
81 
82  private:
83 
85 #if defined (_WIN32)
86  typedef HMODULE lib_handle_t;
87 #else
88  typedef void * lib_handle_t;
89 #endif
90 
91  // Default initializer
92  static void DefaultInitializer();
93 
95  static lib_handle_t OpenLibrary(const gcstring Name);
96 
98  static void *FindSymbol(lib_handle_t Handle, const gcstring Name);
99 
101  static void MakeSureLoggerHasBeenFound();
102 
103  static bool ExistInMap(gcstring loggerName);
104  // Delete all available ILoggers
105  static void DeleteLoggerMap();
106 
107  // Contains the logger factory unless it has not been loaded
109 
110 
111 
113  static lib_handle_t g_pLibHandle;
114 
115  // True if logger has been found
116  static bool m_LoggerHasBeenFound;
117  static bool m_OmitLogger;
118 
119  };
120 
121 }
122 
123 #if defined(__GNUC__)
124 # pragma GCC diagnostic push
125 # pragma GCC diagnostic ignored "-Wvariadic-macros"
126 #endif
127 
128 // Logging macros
129 #define GCLOGINFO( cat, ... ) if(cat && GENICAM_NAMESPACE::CLog::Exist("")) { (cat)->Log(GENICAM_NAMESPACE::ILogger::INFO, ##__VA_ARGS__ ); }
130 #define GCLOGINFOPUSH( cat, ... ) if(cat && GENICAM_NAMESPACE::CLog::Exist("")) { (cat)->Log(GENICAM_NAMESPACE::ILogger::INFO, ##__VA_ARGS__ ); GENICAM_NAMESPACE::CLog::PushIndent();}
131 #define GCLOGWARN( cat, ... ) if(cat && GENICAM_NAMESPACE::CLog::Exist("")) { (cat)->Log(GENICAM_NAMESPACE::ILogger::WARN, ##__VA_ARGS__ ); }
132 #define GCLOGERROR( cat, ... ) if(cat && GENICAM_NAMESPACE::CLog::Exist("")) { (cat)->Log(GENICAM_NAMESPACE::ILogger::ERR, ##__VA_ARGS__ ); }
133 #define GCLOGDEBUG( cat, ... ) if(cat && GENICAM_NAMESPACE::CLog::Exist("")) { (cat)->Log(GENICAM_NAMESPACE::ILogger::DEBUG, ##__VA_ARGS__ ); }
134 #define GCLOGINFOPOP( cat, ... ) if(cat && GENICAM_NAMESPACE::CLog::Exist("")) { (cat)->Log(GENICAM_NAMESPACE::ILogger::INFO, ##__VA_ARGS__ ); GENICAM_NAMESPACE::CLog::PopIndent();}
135 
136 
137 #if defined(__GNUC__)
138 # pragma GCC diagnostic pop
139 #endif
140 
141 #endif // LOG_CLOG_H_
static bool m_LoggerHasBeenFound
Definition: CLog.h:116
void * lib_handle_t
A type corresponds to a library handle which can be platform specific.
Definition: CLog.h:88
static lib_handle_t g_pLibHandle
A handle to an associated logger library.
Definition: CLog.h:113
#define LOG_DECL
Definition: LogDll.h:48
static ILoggerFactory * m_LogFactory
Definition: CLog.h:108
Common GenICam base include file.
static bool m_OmitLogger
Definition: CLog.h:117
declspec&#39;s to be used for Log Windows dll
A string class which is a clone of std::string.
Definition: GCString.h:52
This logging class initializes the logger.
Definition: CLog.h:54


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Mar 17 2021 02:48:40