μHAL (v2.7.9)
Part of the IPbus software repository
log.cpp
Go to the documentation of this file.
1 
2 #include <stdlib.h> // for getenv
3 
4 #include <boost/thread/mutex.hpp> // for mutex
5 
6 #include "uhal/log/LogLevels.hpp" // for BaseLogLevel, Info, Info...
7 #include "uhal/log/log.hpp" // for log
8 #include "uhal/log/log_inserters.quote.hpp" // for operator<<, Quote
9 
10 
11 namespace uhal{
12 
13 // ======================================================================================================================================================
14 // WARNING! This file is automatically generated! Do not modify it! Any changes will be overwritten!
15 // ======================================================================================================================================================
16 
17 void setLogLevelFromEnvironment ( const char* aEnvVar )
18 {
19  char * lEnvVar = getenv ( aEnvVar );
20  if( !lEnvVar )
21  {
22  log( Warning() , "No environment variable " , Quote( aEnvVar ) , " set. Using level " , Quote( "Info" ) , " instead." );
23  setLogLevelTo ( Info() );
24  return;
25  }
26 
27  //Just comparing the first letter of the environment variable for speed!!!
28  switch ( lEnvVar[0] )
29  {
30  case 'f' :
31  case 'F' :
32  setLogLevelTo ( Fatal() );
33  break;
34  case 'e' :
35  case 'E' :
36  setLogLevelTo ( Error() );
37  break;
38  case 'w' :
39  case 'W' :
40  setLogLevelTo ( Warning() );
41  break;
42  case 'n' :
43  case 'N' :
44  setLogLevelTo ( Notice() );
45  break;
46  case 'i' :
47  case 'I' :
48  setLogLevelTo ( Info() );
49  break;
50  case 'd' :
51  case 'D' :
52  setLogLevelTo ( Debug() );
53  break;
54  default:
55 
56  log ( Warning() , "Environment varible has invalid value " , Quote( lEnvVar ) , ". Using level " , Quote ( "Info" ) , " instead." );
57  setLogLevelTo ( Info() );
58  }
59 }
60 
61 // ======================================================================================================================================================
62 // WARNING! This file is automatically generated! Do not modify it! Any changes will be overwritten!
63 // ======================================================================================================================================================
64 
66 {
73 }
74 
75 // ======================================================================================================================================================
76 // WARNING! This file is automatically generated! Do not modify it! Any changes will be overwritten!
77 // ======================================================================================================================================================
78 
79 boost::mutex& GetLoggingMutex()
80 {
82 }
83 
84 // ======================================================================================================================================================
85 // WARNING! This file is automatically generated! Do not modify it! Any changes will be overwritten!
86 // ======================================================================================================================================================
87 
88 void setLogLevelTo ( const FatalLevel& )
89 {
90  #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...
97  #endif
98 }
99 
100 const bool& LoggingIncludes ( const FatalLevel& )
101 {
102  #ifndef LOGGING_EXCLUDE_FATAL
104  #endif
106 }
107 
108 void setLogLevelTo ( const ErrorLevel& )
109 {
110  #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...
112  #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...
118  #endif
119  #endif
120 }
121 
122 const bool& LoggingIncludes ( const ErrorLevel& )
123 {
124  #ifndef LOGGING_EXCLUDE_FATAL
125  #ifndef LOGGING_EXCLUDE_ERROR
127  #endif
128  #endif
130 }
131 
133 {
134  #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...
136  #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...
138  #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...
143  #endif
144  #endif
145  #endif
146 }
147 
148 const bool& LoggingIncludes ( const WarningLevel& )
149 {
150  #ifndef LOGGING_EXCLUDE_FATAL
151  #ifndef LOGGING_EXCLUDE_ERROR
152  #ifndef LOGGING_EXCLUDE_WARNING
154  #endif
155  #endif
156  #endif
158 }
159 
160 void setLogLevelTo ( const NoticeLevel& )
161 {
162  #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...
164  #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...
166  #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...
168  #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...
172  #endif
173  #endif
174  #endif
175  #endif
176 }
177 
178 const bool& LoggingIncludes ( const NoticeLevel& )
179 {
180  #ifndef LOGGING_EXCLUDE_FATAL
181  #ifndef LOGGING_EXCLUDE_ERROR
182  #ifndef LOGGING_EXCLUDE_WARNING
183  #ifndef LOGGING_EXCLUDE_NOTICE
185  #endif
186  #endif
187  #endif
188  #endif
190 }
191 
192 void setLogLevelTo ( const InfoLevel& )
193 {
194  #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...
196  #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...
198  #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...
200  #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...
202  #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...
205  #endif
206  #endif
207  #endif
208  #endif
209  #endif
210 }
211 
212 const bool& LoggingIncludes ( const InfoLevel& )
213 {
214  #ifndef LOGGING_EXCLUDE_FATAL
215  #ifndef LOGGING_EXCLUDE_ERROR
216  #ifndef LOGGING_EXCLUDE_WARNING
217  #ifndef LOGGING_EXCLUDE_NOTICE
218  #ifndef LOGGING_EXCLUDE_INFO
220  #endif
221  #endif
222  #endif
223  #endif
224  #endif
226 }
227 
228 void setLogLevelTo ( const DebugLevel& )
229 {
230  #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...
232  #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...
234  #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...
236  #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...
238  #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...
240  #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...
242  #endif
243  #endif
244  #endif
245  #endif
246  #endif
247  #endif
248 }
249 
250 const bool& LoggingIncludes ( const DebugLevel& )
251 {
252  #ifndef LOGGING_EXCLUDE_FATAL
253  #ifndef LOGGING_EXCLUDE_ERROR
254  #ifndef LOGGING_EXCLUDE_WARNING
255  #ifndef LOGGING_EXCLUDE_NOTICE
256  #ifndef LOGGING_EXCLUDE_INFO
257  #ifndef LOGGING_EXCLUDE_DEBUG
259  #endif
260  #endif
261  #endif
262  #endif
263  #endif
264  #endif
266 }
267 
268 bool log_configuration::mLoggingIncludesFatal = true; // No #ifdefs required here since they are implemented in all the access functions.
269 bool log_configuration::mLoggingIncludesError = true; // No #ifdefs required here since they are implemented in all the access functions.
270 bool log_configuration::mLoggingIncludesWarning = true; // No #ifdefs required here since they are implemented in all the access functions.
271 bool log_configuration::mLoggingIncludesNotice = true; // No #ifdefs required here since they are implemented in all the access functions.
272 bool log_configuration::mLoggingIncludesInfo = true; // No #ifdefs required here since they are implemented in all the access functions.
273 bool log_configuration::mLoggingIncludesDebug = false; // No #ifdefs required here since they are implemented in all the access functions.
274 
275 const bool log_configuration::mTrue = true;
276 const bool log_configuration::mFalse = false;
277 
278 boost::mutex log_configuration::mMutex;
279 
280 // ======================================================================================================================================================
281 // WARNING! This file is automatically generated! Do not modify it! Any changes will be overwritten!
282 // ======================================================================================================================================================
283 
284 }
285 
uhal::NoticeLevel
Helper struct representing the Notice log level to allow us to specialize functions according to thei...
Definition: LogLevels.hpp:130
uhal::log_configuration::mLoggingIncludesWarning
static bool mLoggingIncludesWarning
static bool storing whether the Warning level is to be included in the log output
Definition: log.hpp:126
uhal::log_configuration::mFalse
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:156
uhal::FatalLevel
Helper struct representing the Fatal log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:85
uhal::log_configuration::mLoggingIncludesNotice
static bool mLoggingIncludesNotice
static bool storing whether the Notice level is to be included in the log output
Definition: log.hpp:133
uhal::setLogLevelTo
void setLogLevelTo(const FatalLevel &)
Function to specify, at runtime, that only messages with a severity level above Fatal should be logge...
Definition: log.cpp:88
uhal::log_configuration::mMutex
static boost::mutex mMutex
Define a static Mutex lock for thread safe logging.
Definition: log.hpp:161
uhal::log_configuration::mLoggingIncludesError
static bool mLoggingIncludesError
static bool storing whether the Error level is to be included in the log output
Definition: log.hpp:119
uhal
Definition: HttpResponseGrammar.hpp:49
log_inserters.quote.hpp
uhal::Info
InfoLevel Info
Definition: LogLevels.cpp:115
uhal::log
void log(FatalLevel &aFatal, const T0 &aArg0)
Function to add a log entry at Fatal level.
Definition: log.hxx:20
uhal::LoggingIncludes
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:100
uhal::disableLogging
void disableLogging()
Function to disable all logging levels.
Definition: log.cpp:65
uhal::Warning
WarningLevel Warning
Definition: LogLevels.cpp:79
uhal::Error
ErrorLevel Error
Definition: LogLevels.cpp:61
uhal::Quote
_Quote< T > Quote(const T &aT)
Definition: log_inserters.quote.hxx:49
uhal::log_configuration::mLoggingIncludesInfo
static bool mLoggingIncludesInfo
static bool storing whether the Info level is to be included in the log output
Definition: log.hpp:140
uhal::WarningLevel
Helper struct representing the Warning log level to allow us to specialize functions according to the...
Definition: LogLevels.hpp:116
uhal::InfoLevel
Helper struct representing the Info log level to allow us to specialize functions according to their ...
Definition: LogLevels.hpp:145
uhal::Debug
DebugLevel Debug
Definition: LogLevels.cpp:133
uhal::GetLoggingMutex
boost::mutex & GetLoggingMutex()
Function to retrieve the mutex lock used by the logger.
Definition: log.cpp:79
uhal::Notice
NoticeLevel Notice
Definition: LogLevels.cpp:97
log.hpp
uhal::log_configuration::mLoggingIncludesDebug
static bool mLoggingIncludesDebug
static bool storing whether the Debug level is to be included in the log output
Definition: log.hpp:147
uhal::log_configuration::mLoggingIncludesFatal
static bool mLoggingIncludesFatal
static bool storing whether the Fatal level is to be included in the log output
Definition: log.hpp:112
uhal::DebugLevel
Helper struct representing the Debug log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:159
LogLevels.hpp
uhal::Fatal
FatalLevel Fatal
Definition: LogLevels.cpp:43
uhal::log_configuration::mTrue
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:154
uhal::setLogLevelFromEnvironment
void setLogLevelFromEnvironment(const char *aEnvVar)
Function to specify that the logging level should be retrieved from an environment variable.
Definition: log.cpp:17
uhal::ErrorLevel
Helper struct representing the Error log level to allow us to specialize functions according to their...
Definition: LogLevels.hpp:100