fw4spl
SpyLogger.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWCORE_LOG_SPYLOGGER_HPP__
8 #define __FWCORE_LOG_SPYLOGGER_HPP__
9 
10 #include <iostream>
11 #include <string>
12 
13 
14 #include "fwCore/BaseObject.hpp"
15 #include "fwCore/config.hpp"
16 
17 namespace fwCore
18 {
19 namespace log
20 {
21 
28 {
29 
30 public:
31 
32  enum LevelType
33  {
34  SL_TRACE,
35  SL_DEBUG,
36  SL_INFO,
37  SL_WARN,
38  SL_ERROR,
39  SL_FATAL
40  };
41 
42  FWCORE_API void createBasicConfiguration();
43 
44  FWCORE_API void addStreamAppender(std::ostream &os = std::clog, LevelType level = SL_TRACE);
45 
46  FWCORE_API void addFileAppender(const std::string & logFile = "SLM.log", LevelType level = SL_TRACE);
47 
48  // FWCORE_API void addSyslogAppender(const std::string & hostName, const std::string & facilityName);
49 
50  FWCORE_API void setLevel(LevelType level);
51 
52  FWCORE_API void trace(const std::string & mes, const char * file = 0, int line = -1);
53 
54  FWCORE_API void debug(const std::string & mes, const char * file = 0, int line = -1);
55 
56  FWCORE_API void info(const std::string & mes, const char * file = 0, int line = -1);
57 
58  FWCORE_API void warn(const std::string & mes, const char * file = 0, int line = -1);
59 
60  FWCORE_API void error(const std::string & mes, const char * file = 0, int line = -1);
61 
62  FWCORE_API void fatal(const std::string & mes, const char * file = 0, int line = -1);
63 
64  FWCORE_API void log(const std::string & mes, const char * file = 0, int line = -1);
65 
66  static SpyLogger &getSpyLogger()
67  {
68  return s_spyLogger;
69  }
70 
71 protected:
72 
73 
74  FWCORE_API SpyLogger ();
75 
76  FWCORE_API static SpyLogger s_spyLogger;
77 
78 }; // SpyLogger
79 
80 } // namespace log
81 } // namespace fwCore
82 
83 #endif // __FWCORE_LOG_SPYLOGGER_HPP__
Base class for all FW4SPL&#39;s classes.
Definition: BaseObject.hpp:22
This namespace fwCore provides common foundations for FW4SPL.
Definition: BaseObject.hpp:16
Implements the SpyLogger.
Definition: SpyLogger.hpp:27