LoggingManager.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 #ifndef ICL_CORE_LOGGING_LOGGING_MANAGER_H_INCLUDED
28 #define ICL_CORE_LOGGING_LOGGING_MANAGER_H_INCLUDED
29 
30 #include <icl_core/BaseTypes.h>
31 #include <icl_core/List.h>
32 #include <icl_core/Map.h>
35 
36 #include <boost/shared_ptr.hpp>
37 
38 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
39 # include "icl_core/Deprecate.h"
40 #endif
41 
42 namespace icl_core {
43 namespace logging {
44 
45 class LogOutputStream;
46 class LogStream;
47 
48 typedef LogOutputStream* (*LogOutputStreamFactory)(const icl_core::String& name,
49  const icl_core::String& config_prefix,
50  LogLevel log_level);
51 typedef LogStream* (*LogStreamFactory)();
52 
62 {
63 public:
65  {
66  static LoggingManager manager_instance;
67  return manager_instance;
68  }
69 
75  void configure();
76 
87  void initialize();
88 
91  bool initialized() const { return m_initialized; }
92 
96  void assertInitialized() const;
97 
100  void registerLogOutputStream(const icl_core::String& name, LogOutputStreamFactory factory);
101 
104  void removeLogOutputStream(LogOutputStream *log_output_stream, bool remove_from_list = true);
105 
108  void registerLogStream(const icl_core::String& name, LogStreamFactory factory);
109 
112  void registerLogStream(LogStream *log_stream);
113 
116  void removeLogStream(const icl_core::String& log_stream_name);
117 
122  void printConfiguration() const;
123 
127  void changeLogFormat(const icl_core::String& name, const char *format = "~T ~S(~L)~ C~(O~::D: ~E");
128 
134  void shutdown();
135 
138 
140 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
141 
144 
148  ICL_CORE_VC_DEPRECATE_STYLE void Configure()
150 
156 
160  ICL_CORE_VC_DEPRECATE_STYLE bool Initialized() const
162 
166  ICL_CORE_VC_DEPRECATE_STYLE void AssertInitialized() const
168 
172  ICL_CORE_VC_DEPRECATE_STYLE void RegisterLogOutputStream(const icl_core::String& name,
173  LogOutputStreamFactory factory)
175 
179  ICL_CORE_VC_DEPRECATE_STYLE void RemoveLogOutputStream(LogOutputStream *log_output_stream,
180  bool remove_from_list = true)
182 
186  ICL_CORE_VC_DEPRECATE_STYLE void RegisterLogStream(const icl_core::String& name,
187  LogStreamFactory factory)
189 
193  ICL_CORE_VC_DEPRECATE_STYLE void RegisterLogStream(LogStream *log_stream)
195 
199  ICL_CORE_VC_DEPRECATE_STYLE void RemoveLogStream(const icl_core::String& log_stream_name)
201 
205  ICL_CORE_VC_DEPRECATE_STYLE void PrintConfiguration() const
207 
211  ICL_CORE_VC_DEPRECATE_STYLE void ChangeLogFormat(const icl_core::String& name,
212  const char *format = "~T ~S(~L)~ C~(O~::D: ~E")
214 
218  ICL_CORE_VC_DEPRECATE_STYLE void Shutdown()
220 
221 #endif
222 
224 private:
226 
229  {
239  StringList log_streams;
240  };
242 
245  {
250  };
252 
253  LoggingManager();
254 
255  ~LoggingManager();
256 
257  // Forbid copying logging manager objects.
259  LoggingManager& operator = (const LoggingManager&);
260 
263 
264  LogOutputStreamConfigMap m_output_stream_config;
265  LogStreamConfigMap m_log_stream_config;
266 
271  LogStreamMap m_log_streams;
272  LogOutputStreamFactoryMap m_log_output_stream_factories;
273  LogStreamFactoryMap m_log_stream_factories;
274  LogOutputStreamMap m_log_output_streams;
275 
277 };
278 
280 namespace hidden {
281 
289 {
290 public:
292 };
293 
300 {
301 public:
303 };
304 
305 }
306 
311 {
312 public:
314  typedef boost::shared_ptr<LifeCycle> Ptr;
316  typedef boost::shared_ptr<const LifeCycle> ConstPtr;
317 
319  LifeCycle(int &argc, char *argv[]);
320 
322  ~LifeCycle();
323 };
324 
325 }
326 }
327 
328 #endif
LogOutputStreamFactoryMap m_log_output_stream_factories
bool initialize(int &argc, char *argv[], bool remove_read_arguments)
icl_core::String name
The name of the output stream instance which will be created.
#define ICL_CORE_VC_DEPRECATE_STYLE
Definition: Deprecate.h:53
LogStreamFactoryMap m_log_stream_factories
boost::shared_ptr< const LifeCycle > ConstPtr
Convenience shared pointer shorthand (const version).
Contains macros to deprecate classes, types, functions and variables.
Contains import/export definitions for the Win32 plattform.
static LoggingManager & instance()
icl_core::Map< icl_core::String, LogStreamConfig > LogStreamConfigMap
ICL_CORE_VC_DEPRECATE_STYLE bool Initialize(int &argc, char *argv[], bool remove_read_arguments) ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Config.h:902
icl_core::Map< icl_core::String, LogOutputStreamFactory > LogOutputStreamFactoryMap
Manages the logging framework.
icl_core::Map< icl_core::String, LogStream * > LogStreamMap
LogStream *(* LogStreamFactory)()
LogOutputStream *(* LogOutputStreamFactory)(const icl_core::String &name, const icl_core::String &config_prefix, LogLevel log_level)
icl_core::Map< icl_core::String, LogStreamFactory > LogStreamFactoryMap
LogOutputStream * m_default_log_output
Implements a thread-safe logging framework.
Definition: LogStream.h:54
LogLevel log_level
The log level of this output stream.
icl_core::Map< icl_core::String, LogOutputStream * > LogOutputStreamMap
StringList log_streams
All associated log streams.
void setLogLevel(icl_core::logging::LogLevel log_level)
Set a global log level for all streams.
LogOutputStreamConfigMap m_output_stream_config
LogOutputStreamMap m_log_output_streams
icl_core::String name
Name of the log stream.
This is an output stream class for log messages.
Contains icl_logging::LogLevel.
std::string String
Definition: BaseTypes.h:43
Contains Interface base classes and base types.
icl_core::Map< icl_core::String, LogOutputStreamConfig > LogOutputStreamConfigMap
boost::shared_ptr< LifeCycle > Ptr
Convenience shared pointer shorthand.
LogLevel log_level
Log level of the log stream.
LogStreamConfigMap m_log_stream_config
#define ICL_CORE_LOGGING_IMPORT_EXPORT
icl_core::List< icl_core::String > StringList
#define ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Deprecate.h:54


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58