m2etis  0.4
Logger.h
Go to the documentation of this file.
1 /*
2  Copyright (2016) Michael Baer, Daniel Bonrath, All rights reserved.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16 
22 #ifndef __M2ETIS_UTIL_LOGGER_H__
23 #define __M2ETIS_UTIL_LOGGER_H__
24 
25 
26 #ifdef WITH_LOGGING
27  #define GLOG_NO_ABBREVIATED_SEVERITIES
28  #include <glog/logging.h>
29 #endif
30 
31 
32 #ifdef WITH_LOGGING
33  #define M2ETIS_LOG_DEBUG(module, message) {\
34  DLOG(INFO) << message;\
35  }
36  #define M2ETIS_LOG_INFO(module, message) {\
37  LOG(INFO) << message;\
38  }
39  #define M2ETIS_LOG_WARN(module, message) {\
40  LOG(WARNING) << message;\
41  }
42  #define M2ETIS_LOG_ERROR(module, message) {\
43  LOG(ERROR) << message;\
44  }
45  #define M2ETIS_LOG_FATAL(module, message) {\
46  LOG(FATAL) << message;\
47  }
48 
49  #define M2ETIS_LOG_SETLEVEL(level) {\
50  m2etis::util::Logger::GetSingleton().SetLogLevel(level);\
51  }
52 #else
53  #define M2ETIS_LOG_DEBUG(module, message) {\
54  }
55  #define M2ETIS_LOG_INFO(module, message) {\
56  }
57  #define M2ETIS_LOG_WARN(module, message) {\
58  }
59  #define M2ETIS_LOG_ERROR(module, message) {\
60  }
61  #define M2ETIS_LOG_FATAL(module, message) {\
62  }
63 
64  #define M2ETIS_LOG_SETLEVEL(level) {\
65  }
66 #endif /* WITH_LOGGING */
67 
68 namespace m2etis {
69 namespace util {
70 namespace log {
75 #ifdef WITH_LOGGING
76  extern bool loggingOn;
77 
78  enum LogLevel {
79  LOG_INFO = google::GLOG_INFO,
80  LOG_WARN = google::GLOG_WARNING,
81  LOG_ERROR = google::GLOG_ERROR,
82  LOG_FATAL = google::GLOG_FATAL,
83  LOG_NONE = 5
84  };
85 #else /* WITH_LOGGING */
86  enum LogLevel {
87  LOG_INFO = 0,
92  };
93 #endif /* WITH_LOGGING */
94 
95  void initializeLogging();
96  void shutdownLogging();
97 
98 } /* namespace log */
99 } /* namespace util */
100 } /* namespace m2etis */
101 
102 #endif /* __M2ETIS_UTIL_LOGGER_H__ */
103 
LogLevel
Defines values to specify severity/importance of log message.
Definition: Logger.h:86
void initializeLogging()