μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
log.cpp
Go to the documentation of this file.
1
2#include <mutex> // for lock_guard, mutex
3#include <stdlib.h> // for getenv
4
5#include "uhal/log/LogLevels.hpp" // for BaseLogLevel, Info, Info...
6#include "uhal/log/log.hpp" // for log
7#include "uhal/log/log_inserters.quote.hpp" // for operator<<, Quote
8
9
10namespace uhal{
11
12// ======================================================================================================================================================
13// WARNING! This file is automatically generated! Do not modify it! Any changes will be overwritten!
14// ======================================================================================================================================================
15
16void setLogLevelFromEnvironment ( const char* aEnvVar )
17{
18 char * lEnvVar = getenv ( aEnvVar );
19 if( !lEnvVar )
20 {
21 log( Warning() , "No environment variable " , Quote( aEnvVar ) , " set. Using level " , Quote( "Info" ) , " instead." );
22 setLogLevelTo ( Info() );
23 return;
24 }
25
26 //Just comparing the first letter of the environment variable for speed!!!
27 switch ( lEnvVar[0] )
28 {
29 case 'f' :
30 case 'F' :
31 setLogLevelTo ( Fatal() );
32 break;
33 case 'e' :
34 case 'E' :
35 setLogLevelTo ( Error() );
36 break;
37 case 'w' :
38 case 'W' :
40 break;
41 case 'n' :
42 case 'N' :
44 break;
45 case 'i' :
46 case 'I' :
47 setLogLevelTo ( Info() );
48 break;
49 case 'd' :
50 case 'D' :
51 setLogLevelTo ( Debug() );
52 break;
53 default:
54
55 log ( Warning() , "Environment varible has invalid value " , Quote( lEnvVar ) , ". Using level " , Quote ( "Info" ) , " instead." );
56 setLogLevelTo ( Info() );
57 }
58}
59
60// ======================================================================================================================================================
61// WARNING! This file is automatically generated! Do not modify it! Any changes will be overwritten!
62// ======================================================================================================================================================
63
65{
72}
73
74// ======================================================================================================================================================
75// WARNING! This file is automatically generated! Do not modify it! Any changes will be overwritten!
76// ======================================================================================================================================================
77
78std::mutex& GetLoggingMutex()
79{
81}
82
83// ======================================================================================================================================================
84// WARNING! This file is automatically generated! Do not modify it! Any changes will be overwritten!
85// ======================================================================================================================================================
86
88{
89 #ifndef LOGGING_EXCLUDE_FATAL // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
96 #endif
97}
98
99const bool& LoggingIncludes ( const FatalLevel& )
100{
101 #ifndef LOGGING_EXCLUDE_FATAL
103 #endif
105}
106
108{
109 #ifndef LOGGING_EXCLUDE_FATAL // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
111 #ifndef LOGGING_EXCLUDE_ERROR // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
117 #endif
118 #endif
119}
120
121const bool& LoggingIncludes ( const ErrorLevel& )
122{
123 #ifndef LOGGING_EXCLUDE_FATAL
124 #ifndef LOGGING_EXCLUDE_ERROR
126 #endif
127 #endif
129}
130
132{
133 #ifndef LOGGING_EXCLUDE_FATAL // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
135 #ifndef LOGGING_EXCLUDE_ERROR // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
137 #ifndef LOGGING_EXCLUDE_WARNING // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
142 #endif
143 #endif
144 #endif
145}
146
147const bool& LoggingIncludes ( const WarningLevel& )
148{
149 #ifndef LOGGING_EXCLUDE_FATAL
150 #ifndef LOGGING_EXCLUDE_ERROR
151 #ifndef LOGGING_EXCLUDE_WARNING
153 #endif
154 #endif
155 #endif
157}
158
160{
161 #ifndef LOGGING_EXCLUDE_FATAL // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
163 #ifndef LOGGING_EXCLUDE_ERROR // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
165 #ifndef LOGGING_EXCLUDE_WARNING // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
167 #ifndef LOGGING_EXCLUDE_NOTICE // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
171 #endif
172 #endif
173 #endif
174 #endif
175}
176
177const bool& LoggingIncludes ( const NoticeLevel& )
178{
179 #ifndef LOGGING_EXCLUDE_FATAL
180 #ifndef LOGGING_EXCLUDE_ERROR
181 #ifndef LOGGING_EXCLUDE_WARNING
182 #ifndef LOGGING_EXCLUDE_NOTICE
184 #endif
185 #endif
186 #endif
187 #endif
189}
190
192{
193 #ifndef LOGGING_EXCLUDE_FATAL // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
195 #ifndef LOGGING_EXCLUDE_ERROR // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
197 #ifndef LOGGING_EXCLUDE_WARNING // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
199 #ifndef LOGGING_EXCLUDE_NOTICE // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
201 #ifndef LOGGING_EXCLUDE_INFO // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
204 #endif
205 #endif
206 #endif
207 #endif
208 #endif
209}
210
211const bool& LoggingIncludes ( const InfoLevel& )
212{
213 #ifndef LOGGING_EXCLUDE_FATAL
214 #ifndef LOGGING_EXCLUDE_ERROR
215 #ifndef LOGGING_EXCLUDE_WARNING
216 #ifndef LOGGING_EXCLUDE_NOTICE
217 #ifndef LOGGING_EXCLUDE_INFO
219 #endif
220 #endif
221 #endif
222 #endif
223 #endif
225}
226
228{
229 #ifndef LOGGING_EXCLUDE_FATAL // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
231 #ifndef LOGGING_EXCLUDE_ERROR // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
233 #ifndef LOGGING_EXCLUDE_WARNING // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
235 #ifndef LOGGING_EXCLUDE_NOTICE // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
237 #ifndef LOGGING_EXCLUDE_INFO // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
239 #ifndef LOGGING_EXCLUDE_DEBUG // A waste of time to change any level below this if it is going to disabled by compile-time checking anyway...
241 #endif
242 #endif
243 #endif
244 #endif
245 #endif
246 #endif
247}
248
249const bool& LoggingIncludes ( const DebugLevel& )
250{
251 #ifndef LOGGING_EXCLUDE_FATAL
252 #ifndef LOGGING_EXCLUDE_ERROR
253 #ifndef LOGGING_EXCLUDE_WARNING
254 #ifndef LOGGING_EXCLUDE_NOTICE
255 #ifndef LOGGING_EXCLUDE_INFO
256 #ifndef LOGGING_EXCLUDE_DEBUG
258 #endif
259 #endif
260 #endif
261 #endif
262 #endif
263 #endif
265}
266
267bool log_configuration::mLoggingIncludesFatal = true; // No #ifdefs required here since they are implemented in all the access functions.
268bool log_configuration::mLoggingIncludesError = true; // No #ifdefs required here since they are implemented in all the access functions.
269bool log_configuration::mLoggingIncludesWarning = true; // No #ifdefs required here since they are implemented in all the access functions.
270bool log_configuration::mLoggingIncludesNotice = true; // No #ifdefs required here since they are implemented in all the access functions.
271bool log_configuration::mLoggingIncludesInfo = true; // No #ifdefs required here since they are implemented in all the access functions.
272bool log_configuration::mLoggingIncludesDebug = false; // No #ifdefs required here since they are implemented in all the access functions.
273
274const bool log_configuration::mTrue = true;
275const bool log_configuration::mFalse = false;
276
278
279// ======================================================================================================================================================
280// WARNING! This file is automatically generated! Do not modify it! Any changes will be overwritten!
281// ======================================================================================================================================================
282
283}
284
Helper struct representing the Debug log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:159
Helper struct representing the Error log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:100
Helper struct representing the Fatal log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:85
Helper struct representing the Info log level to allow us to specialize functions according to their ...
Definition: LogLevels.hpp:145
Helper struct representing the Notice log level to allow us to specialize functions according to thei...
Definition: LogLevels.hpp:130
Helper struct representing the Warning log level to allow us to specialize functions according to the...
Definition: LogLevels.hpp:116
static const bool mFalse
Define a static const member variable to have a value of false so that we can safely return a const r...
Definition: log.hpp:155
static bool mLoggingIncludesNotice
static bool storing whether the Notice level is to be included in the log output
Definition: log.hpp:132
static bool mLoggingIncludesWarning
static bool storing whether the Warning level is to be included in the log output
Definition: log.hpp:125
static bool mLoggingIncludesFatal
static bool storing whether the Fatal level is to be included in the log output
Definition: log.hpp:111
static bool mLoggingIncludesError
static bool storing whether the Error level is to be included in the log output
Definition: log.hpp:118
static std::mutex mMutex
Define a static Mutex lock for thread safe logging.
Definition: log.hpp:160
static bool mLoggingIncludesDebug
static bool storing whether the Debug level is to be included in the log output
Definition: log.hpp:146
static bool mLoggingIncludesInfo
static bool storing whether the Info level is to be included in the log output
Definition: log.hpp:139
static const bool mTrue
Define a static const member variable to have a value of true so that we can safely return a const re...
Definition: log.hpp:153
DebugLevel Debug
Definition: LogLevels.cpp:133
_Quote< T > Quote(const T &aT)
void setLogLevelTo(const FatalLevel &)
Function to specify, at runtime, that only messages with a severity level above Fatal should be logge...
Definition: log.cpp:87
const bool & LoggingIncludes(const FatalLevel &)
Function to check at runtime whether the level Fatal is to be included in the log output.
Definition: log.cpp:99
ErrorLevel Error
Definition: LogLevels.cpp:61
void log(FatalLevel &aFatal, const T0 &aArg0)
Function to add a log entry at Fatal level.
Definition: log.hxx:18
std::mutex & GetLoggingMutex()
Function to retrieve the mutex lock used by the logger.
Definition: log.cpp:78
void disableLogging()
Function to disable all logging levels.
Definition: log.cpp:64
FatalLevel Fatal
Definition: LogLevels.cpp:43
WarningLevel Warning
Definition: LogLevels.cpp:79
InfoLevel Info
Definition: LogLevels.cpp:115
NoticeLevel Notice
Definition: LogLevels.cpp:97
void setLogLevelFromEnvironment(const char *aEnvVar)
Function to specify that the logging level should be retrieved from an environment variable.
Definition: log.cpp:16