4S Device Communication Module Collection  Version 0.6-SNAPSHOT
Full documentation of the modules in the 4SDC collection (aimed at 4SDC module developers)
log.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2015 The 4S Foundation (www.4s-online.dk)
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 
32 #ifndef LOG_H
33 #define LOG_H
34 
35 #include <string>
36 
37 namespace FSYS
38 {
97  class Log
98  {
99  protected:
107  void *me;
108  public:
109 
126  Log(std::string const &module);
127  ~Log();
128 
143  static void fatal(std::string const &fatal);
144 
158  static void err (std::string const &err);
159 
174  static void warn (std::string const &warn);
175 
189  static void debug(std::string const &debug);
190 
204  static void info (std::string const &info);
205 
206  void fatal(std::string const &fatal, std::string const &file, int line);
207  void err (std::string const &err, std::string const &file, int line);
208  void warn (std::string const &warn, std::string const &file, int line);
209  void debug(std::string const &debug, std::string const &file, int line);
210  void info (std::string const &info, std::string const &file, int line);
211 
212 #define DECLARE_LOG_MODULE(module) namespace {FSYS::Log eRRORlOG(module);}
213 
214 #define FATAL(msg) eRRORlOG.fatal(msg, __FILE__, __LINE__);
215 #define ERR(msg) eRRORlOG.err (msg, __FILE__, __LINE__);
216 #define WARN(msg) eRRORlOG.warn (msg, __FILE__, __LINE__);
217 #define DEBUG(msg) eRRORlOG.debug(msg, __FILE__, __LINE__);
218 #define INFO(msg) eRRORlOG.info (msg, __FILE__, __LINE__);
219 
220  };
221 
222 }
223 
224 #endif // LOG_H
static void debug(std::string const &debug)
Static function to log debug messages.
Definition: log.cpp:157
Log(std::string const &module)
The Log constructor.
Definition: log.cpp:134
Definition: basemsg.h:38
static void err(std::string const &err)
Static function to log messages about error conditions in the code.
Definition: log.cpp:147
static void warn(std::string const &warn)
Static function to log warning messages from the code.
Definition: log.cpp:152
void * me
The me member is available for use for actuall implementations.
Definition: log.h:107
static void info(std::string const &info)
Static function to log info messages.
Definition: log.cpp:162
static void fatal(std::string const &fatal)
Static function to log messages about fatal incidents in the code.
Definition: log.cpp:142
Log class used for logging information about program execution.
Definition: log.h:97