fw4spl
fwLog/include/fwLog/Logger.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
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 __FWLOG_LOGGER_HPP__
8 #define __FWLOG_LOGGER_HPP__
9 
10 #include "fwLog/Log.hpp"
11 #include "fwLog/config.hpp"
12 
13 #include <fwTools/Object.hpp>
14 
15 #include <string>
16 
17 namespace fwLog
18 {
19 
23 class FWLOG_CLASS_API Logger : public ::fwTools::Object
24 {
25 
26 public:
27 
29 
30  typedef std::vector< ::fwLog::Log > LogContainerType;
31  typedef LogContainerType::iterator IteratorType;
32  typedef LogContainerType::const_iterator ConstIteratorType;
33  typedef LogContainerType::reverse_iterator ReverseIteratorType;
34  typedef LogContainerType::const_reverse_iterator ConstReverseIteratorType;
35 
37  FWLOG_API Logger();
38 
40  FWLOG_API ~Logger();
41 
46  FWLOG_API void information(const std::string& message);
47 
52  FWLOG_API void warning(const std::string& message);
53 
58  FWLOG_API void critical(const std::string& message);
59 
64  FWLOG_API ::fwLog::Log getLog(unsigned int index);
65 
67  FWLOG_API std::size_t count() const;
68 
73  FWLOG_API std::size_t count(::fwLog::Log::LevelType level) const;
74 
78  FWLOG_API void sort();
79 
83  FWLOG_API void clear();
84 
86  bool empty() const
87  {
88  return m_logContainer.empty();
89  }
90 
91  IteratorType begin()
92  {
93  return m_logContainer.begin();
94  }
95  IteratorType end()
96  {
97  return m_logContainer.end();
98  }
99  ConstIteratorType begin() const
100  {
101  return m_logContainer.begin();
102  }
103  ConstIteratorType end() const
104  {
105  return m_logContainer.end();
106  }
107 
108  ReverseIteratorType rbegin()
109  {
110  return m_logContainer.rbegin();
111  }
112  ReverseIteratorType rend()
113  {
114  return m_logContainer.rend();
115  }
116  ConstReverseIteratorType rbegin() const
117  {
118  return m_logContainer.rbegin();
119  }
120  ConstReverseIteratorType rend() const
121  {
122  return m_logContainer.rend();
123  }
124 
125 protected:
126 
132  static bool logSorter(const ::fwLog::Log& logA, const ::fwLog::Log& logB);
133 
135  LogContainerType m_logContainer;
136 
137 
138 }; // class Logger
139 
140 } // namespace fwLog
141 
142 #endif // __FWLOG_LOGGER_HPP__
Define Base class for FW4SPL objects and services.
bool empty() const
Return whether the logger contains logs or not.
fwLog contains classes used to manage logs.
Definition: Log.hpp:16
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
LogContainerType m_logContainer
Log container.
Logger class used to store logs.