LogStream.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 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 #ifndef ICL_CORE_LOGGING_LOG_STREAM_H_INCLUDED
29 #define ICL_CORE_LOGGING_LOG_STREAM_H_INCLUDED
30 
31 
32 #include <list>
33 #include <map>
34 #include <set>
35 #include <string>
36 
37 #include "icl_core/BaseTypes.h"
38 #include "icl_core/Noncopyable.h"
39 #include "icl_core/os_thread.h"
43 
44 namespace icl_core {
45 namespace logging {
46 
47 class LogOutputStream;
48 class LogStream;
50 
51 typedef std::set<LogStream*> LogStreamSet;
52 
55 {
56  friend class LoggingManager;
57  friend class ThreadStream;
58 
59 public:
64 
65  ~LogStream();
66 
68  icl_core::String name() const { return m_name; }
69  const char *nameCStr() const { return m_name.c_str(); }
70 
72  void setActive(bool active = true) { m_active = active; }
73 
75  icl_core::logging::LogLevel initialLogLevel() const { return m_initial_level; }
76 
78  bool isActive() const { return m_active; }
79 
81  icl_core::logging::LogLevel getLogLevel() const;
82 
86  void addOutputStream(LogOutputStream *new_stream);
87 
91  void removeOutputStream(LogOutputStream *stream);
92 
99 
101  void printConfiguration() const;
102 
104 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
105 
110 
111  ICL_CORE_VC_DEPRECATE_STYLE const char *NameCStr() const ICL_CORE_GCC_DEPRECATE_STYLE;
112 
116  ICL_CORE_VC_DEPRECATE_STYLE void SetActive(bool active = true) ICL_CORE_GCC_DEPRECATE_STYLE;
117 
122 
127 
130 
136 
142 
146  ICL_CORE_VC_DEPRECATE_STYLE void PrintConfiguration() const ICL_CORE_GCC_DEPRECATE_STYLE;
147 
156 
157 #endif
158 
160 private:
161  void releaseThreadStream(icl_core::logging::ThreadStream *thread_stream);
162 
164 
166  {
168  icl_core::logging::LogLevel log_level,
169  icl_core::logging::ThreadStream *thread_stream)
170  : thread_id(thread_id),
171  log_level(log_level),
172  thread_stream(thread_stream)
173  { }
174 
178  };
179  typedef std::list<ThreadStreamInfo> ThreadStreamMap;
180  ThreadStreamMap m_thread_stream_map;
181 
183  bool m_active;
184  std::set<LogOutputStream*> m_output_stream_list;
185 
186  // Safe access to the output stream list.
188 
190 };
191 
192 }
193 }
194 
195 #endif
static ThreadId m_empty_thread_id
Definition: LogStream.h:189
ICL_CORE_OS_IMPL_NS::ThreadId ThreadId
Definition: os_thread.h:49
ThreadStreamInfo(ThreadId thread_id, icl_core::logging::LogLevel log_level, icl_core::logging::ThreadStream *thread_stream)
Definition: LogStream.h:167
#define ICL_CORE_VC_DEPRECATE_STYLE
Definition: Deprecate.h:53
const LogLevel cDEFAULT_LOG_LEVEL
The log level which is used initially.
Definition: LogLevel.h:60
#define ICL_CORE_GCC_DEPRECATE_STYLE_USE(arg)
Definition: Deprecate.h:67
icl_core::logging::LogLevel m_initial_level
Definition: LogStream.h:163
Contains import/export definitions for the Win32 plattform.
const char * nameCStr() const
Definition: LogStream.h:69
icl_core::logging::LogLevel initialLogLevel() const
Get the initial log level of this log stream.
Definition: LogStream.h:75
#define ICL_CORE_VC_DEPRECATE_STYLE_USE(arg)
Definition: Deprecate.h:66
ThreadStreamMap m_thread_stream_map
Definition: LogStream.h:180
void setActive(bool active=true)
Activates or deactivates the log stream.
Definition: LogStream.h:72
std::list< ThreadStreamInfo > ThreadStreamMap
Definition: LogStream.h:179
Manages the logging framework.
Implements a thread-safe logging framework.
Definition: LogStream.h:54
Contains global thread related functions, encapsulated into the icl_core::os namespace.
icl_core::logging::ThreadStream * thread_stream
Definition: LogStream.h:177
std::set< LogOutputStream * > m_output_stream_list
Definition: LogStream.h:184
bool isActive() const
Checks if the log stream is active.
Definition: LogStream.h:78
Implements a platform independent mutex.
Definition: Semaphore.h:44
This is an output stream class for log messages.
Contains icl_logging::LogLevel.
std::string String
Definition: BaseTypes.h:43
Implements the actual logging for an individual thread.
Definition: ThreadStream.h:58
icl_core::logging::LogLevel log_level
Definition: LogStream.h:176
Contains Interface base classes and base types.
icl_core::String name() const
Return the name of the log stream.
Definition: LogStream.h:68
icl_core::logging::LogLevel getLogLevel() const
Get the log level of the current thread.
Definition: LogStream.cpp:66
Contains icl_core::Noncopyable.
#define ICL_CORE_LOGGING_IMPORT_EXPORT
std::set< LogStream * > LogStreamSet
Definition: LogStream.h:49
#define ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Deprecate.h:54
Contains icl_core::logging::Semaphore.
icl_core::String m_name
Definition: LogStream.h:182


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