30 #include <boost/lexical_cast.hpp> 31 #include <boost/tuple/tuple.hpp> 53 while (output_stream_it.
next())
57 if (value_name ==
"OutputStreamName")
61 else if (value_name ==
"Name")
65 else if (value_name ==
"LogLevel")
69 std::cerr <<
"LOGGING CONFIG ERROR: Illegal log level in " << output_stream_it.
key() <<
std::endl;
72 else if (value_name.substr(0, 9) ==
"LogStream")
81 while (log_stream_it.
next())
85 if (value_name ==
"Name")
89 else if (value_name ==
"LogLevel")
93 std::cerr <<
"LOGGING CONFIG ERROR: Illegal log level in " << log_stream_it.
key() <<
std::endl;
103 if (icl_core::config::paramOpt<icl_core::String>(
"quick-debug", quick_debug_filename))
115 + boost::lexical_cast<icl_core::String>(count));
118 output_stream_name = output_stream_name + boost::lexical_cast<
icl_core::String>(count);
125 QuickDebug::instance().addOutputStream(output_stream);
126 QuickDebug::instance().m_initial_level =
eLL_TRACE;
138 output_stream_it->second->start();
181 loc_it->second.
name = loc_it->second.output_stream_name;
185 LogOutputStreamMap::const_iterator find_log_output_stream =
189 LogOutputStreamFactoryMap::const_iterator find_log_output_stream_factory =
198 (*find_log_output_stream_factory->second)(loc_it->second.name,
199 "/IclCore/Logging/" + loc_it->first,
200 loc_it->second.log_level);
201 boost::tuples::tie(find_log_output_stream, boost::tuples::ignore) =
210 if (loc_it->second.log_streams.empty())
214 it->second->addOutputStream(find_log_output_stream->second);
219 for (StringList::const_iterator it = loc_it->second.log_streams.begin();
220 it != loc_it->second.log_streams.end(); ++it)
232 find_it->second->addOutputStream(find_log_output_stream->second);
244 LogStreamMap::iterator find_it =
m_log_streams.find(lsc_it->second.name);
254 find_it->second->m_initial_level = lsc_it->second.log_level;
265 std::cerr <<
"Illegal log level " << log_level <<
std::endl;
266 std::cerr <<
"Valid levels are 'Trace', 'Debug', 'Info', 'Warning', 'Error' and 'Mute'." <<
std::endl;
278 lsm_it->second->m_initial_level = initial_level;
285 los_it->second->setLogLevel(initial_level);
295 lsm_it->second->m_initial_level = log_level;
301 los_it->second->setLogLevel(log_level);
320 for (LogStreamMap::iterator log_stream_it =
m_log_streams.begin();
324 log_stream_it->second->removeOutputStream(log_output_stream);
327 if (remove_from_list)
363 "Override the log level of all streams and connect them to stdout. " 364 "Possible values are 'Trace', 'Debug', 'Info', 'Warning', 'Error' and 'Mute'.";
367 "quick-debug:",
"qd",
368 "Activate the QuickDebug log stream and write it " 369 "to the specified file."));
379 std::cerr <<
"LoggingManager configuration:" <<
std::endl;
381 std::cerr <<
" Log output stream factories:" <<
std::endl;
385 std::cerr <<
" " << it->first <<
std::endl;
388 std::cerr <<
" Log output streams:" <<
std::endl;
396 it->second->printConfiguration();
399 std::cerr <<
" Log streams:" <<
std::endl;
402 std::cerr <<
" " << it->first <<
" -> ";
403 it->second->printConfiguration();
413 if (it->first == name)
415 it->second->changeLogFormat(format);
442 output_stream_it->second->shutdown();
443 delete output_stream_it->second;
450 for (LogStreamMap::iterator log_stream_it =
m_log_streams.begin();
454 delete log_stream_it->second;
464 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 474 void LoggingManager::Configure()
490 bool LoggingManager::Initialized()
const 498 void LoggingManager::AssertInitialized()
const 515 void LoggingManager::RemoveLogOutputStream(
LogOutputStream *log_output_stream,
516 bool remove_from_list)
533 void LoggingManager::RegisterLogStream(
LogStream *log_stream)
541 void LoggingManager::RemoveLogStream(
const icl_core::String& log_stream_name)
549 void LoggingManager::PrintConfiguration()
const 566 void LoggingManager::Shutdown()
LogOutputStreamFactoryMap m_log_output_stream_factories
bool initialize(int &argc, char *argv[], bool remove_read_arguments)
LifeCycle(int &argc, char *argv[])
Contains icl_logging::LoggingManager.
Contains GetoptParameter.
LogStreamFactoryMap m_log_stream_factories
void setLogLevel(icl_core::logging::LogLevel log_level)
const LogLevel cDEFAULT_LOG_LEVEL
The log level which is used initially.
known command line options are removed
static LoggingManager & instance()
icl_core::String paramOpt(const icl_core::String &name) const
bool paramOptPresent(const icl_core::String &name) const
void start()
Starts the worker thread of the log output stream.
Base header file for the configuration framework.
Contains icl_logging::StdLogOutput.
void addOutputStream(LogOutputStream *new_stream)
ICL_CORE_VC_DEPRECATE_STYLE bool Initialize(int &argc, char *argv[], bool remove_read_arguments) ICL_CORE_GCC_DEPRECATE_STYLE
bool stringToLogLevel(const std::string &log_level_text, LogLevel &log_level)
Manages the logging framework.
LogStream *(* LogStreamFactory)()
void removeLogOutputStream(LogOutputStream *log_output_stream, bool remove_from_list=true)
LogOutputStream *(* LogOutputStreamFactory)(const icl_core::String &name, const icl_core::String &config_prefix, LogLevel log_level)
LogOutputStream * m_default_log_output
Implements a thread-safe logging framework.
ThreadStream & endl(ThreadStream &stream)
void assertInitialized() const
ConfigIterator find(const ::icl_core::String &query)
LogOutputStreamConfigMap m_output_stream_config
void addParameter(const ConfigParameter ¶meter)
LogOutputStreamMap m_log_output_streams
Contains global LXRT functions.
void setLogLevel(icl_core::logging::LogLevel log_level)
Set the log level globally for all existing streams.
String matchGroup(size_t index) const
void removeLogStream(const icl_core::String &log_stream_name)
This is an output stream class for log messages.
options not registered are ignored
static LogOutputStream * create(const icl_core::String &name, const icl_core::String &config_prefix, icl_core::logging::LogLevel log_level=cDEFAULT_LOG_LEVEL)
void changeLogFormat(const icl_core::String &name, const char *format="~T ~S(~L)~ C~(O~::D: ~E")
Contains icl_logging::FileLogOutput.
Contains icl_logging::LogStream.
icl_core::String name() const
Return the name of the log stream.
static Getopt & instance()
void registerLogStream(const icl_core::String &name, LogStreamFactory factory)
void printConfiguration() const
LogStreamConfigMap m_log_stream_config
ConvertToRef< T >::ToConstRef value() const
void printConfiguration() const
void registerLogOutputStream(const icl_core::String &name, LogOutputStreamFactory factory)
LogStreamMap m_log_streams
icl_core::String name() const