|
OpenWalnut
1.2.5
|
This class defines the interface for adding logs and managing several output streams for them. More...
#include <WLogger.h>
Public Types | |
| enum | LogEvent { AddLog = 0 } |
| Types of signals supported by the logger. More... | |
| typedef boost::function< void(WLogEntry &) > | LogEntryCallback |
| The type for all callbacks which get a log entry as parameter. | |
Public Member Functions | |
| virtual | ~WLogger () |
| Destructor. | |
| void | addStream (WLogStream::SharedPtr s) |
| Adds a new stream to the logger. | |
| void | setDefaultFormat (std::string format) |
| Set the default format used for log entries. | |
| void | setDefaultLogLevel (const LogLevel &level) |
| Set the default log-level used for log entries in default console-output. | |
| std::string | getDefaultFormat () |
| Gets the default format used for log entries. | |
| void | addLogMessage (std::string message, std::string source="", LogLevel level=LL_DEBUG) |
| Appends a log message to the logging queue. | |
| boost::signals2::connection | subscribeSignal (LogEvent event, LogEntryCallback callback) |
| Subscribe to the specified signal. | |
Static Public Member Functions | |
| static void | startup (std::ostream &output=std::cout, LogLevel level=LL_DEBUG) |
| Create the first and only instance of the logger as it is a singleton. | |
| static WLogger * | getLogger () |
| Returns pointer to the currently running logger instance. | |
Private Types | |
| typedef WSharedSequenceContainer < std::vector < WLogStream::SharedPtr > > | Outputs |
| The output stream list type. | |
Private Member Functions | |
| WLogger (std::ostream &output, LogLevel level) | |
| Constructor. | |
| WLogger (const WLogger &) | |
| We do not want a copy constructor, so we define it private. | |
Private Attributes | |
| Outputs | m_outputs |
| The list of outputs to print the messages to. | |
| boost::signals2::signal< void(WLogEntry &) > | m_addLogSignal |
| Signal called whenever a new log message arrives. | |
This class defines the interface for adding logs and managing several output streams for them.
The actual log entry is in WLogEntry and the output is done in WLogStream.
| typedef boost::function< void ( WLogEntry& ) > WLogger::LogEntryCallback |
|
private |
| enum WLogger::LogEvent |
|
virtual |
Destructor.
Definition at line 60 of file WLogger.cpp.
|
private |
Constructor.
The logger is created using the static method startup.
| output | the stream where to print log messages to |
| level | logging level, i.e. verboseness |
Definition at line 49 of file WLogger.cpp.
References addLogMessage(), m_outputs, and WSharedSequenceContainer< S >::push_back().
Referenced by startup().
|
private |
We do not want a copy constructor, so we define it private.
| void WLogger::addLogMessage | ( | std::string | message, |
| std::string | source = "", |
||
| LogLevel | level = LL_DEBUG |
||
| ) |
Appends a log message to the logging queue.
| message | the log entry |
| source | indicates where this entry comes from |
| level | The logging level of the current message |
Definition at line 84 of file WLogger.cpp.
References WSharedObject< T >::getReadTicket(), m_addLogSignal, and m_outputs.
Referenced by WModuleContainer::add(), WDataHandler::addSubject(), WDataHandler::clear(), WModuleConnector::connect(), WModuleConnector::disconnect(), WKernel::finalize(), WModuleFactory::load(), WModuleLoader::load(), WGraphicsEngine::notifyStop(), WGEShader::processShaderRecursive(), WGEShader::reloadShader(), WModuleContainer::remove(), WModuleContainer::removeDeep(), WDataHandler::removeSubject(), WModuleContainer::stop(), WThreadedRunner::threadMain(), WKernel::threadMain(), WGraphicsEngine::threadMain(), WModule::threadMain(), WDataHandler::WDataHandler(), WGEScene::WGEScene(), WGraphicsEngine::WGraphicsEngine(), WKernel::WKernel(), WLogger(), WModuleContainer::WModuleContainer(), wlog::WStreamedLogger::Buffer::~Buffer(), WGEScene::~WGEScene(), WGraphicsEngine::~WGraphicsEngine(), and WKernel::~WKernel().
| void WLogger::addStream | ( | WLogStream::SharedPtr | s | ) |
Adds a new stream to the logger.
This is useful to register file streams or uncolored GUI based outputs.
| s | the stream to add. |
Definition at line 116 of file WLogger.cpp.
References m_outputs, and WSharedSequenceContainer< S >::push_back().
| std::string WLogger::getDefaultFormat | ( | ) |
Gets the default format used for log entries.
This actually returns the format of the first log stream.
Definition at line 111 of file WLogger.cpp.
References m_outputs.
|
static |
Returns pointer to the currently running logger instance.
Definition at line 64 of file WLogger.cpp.
Referenced by WModuleContainer::add(), WDataHandler::addSubject(), WDataHandler::clear(), WModuleConnector::connect(), WModuleConnector::disconnect(), WKernel::finalize(), WModuleFactory::load(), WModuleLoader::load(), WGraphicsEngine::notifyStop(), WGEShader::processShaderRecursive(), WGEShader::reloadShader(), WModuleContainer::remove(), WModuleContainer::removeDeep(), WDataHandler::removeSubject(), WModuleContainer::stop(), WThreadedRunner::threadMain(), WKernel::threadMain(), WGraphicsEngine::threadMain(), WModule::threadMain(), WDataHandler::WDataHandler(), WGEScene::WGEScene(), WGraphicsEngine::WGraphicsEngine(), WKernel::WKernel(), WModuleContainer::WModuleContainer(), wlog::WStreamedLogger::Buffer::~Buffer(), WGEScene::~WGEScene(), WGraphicsEngine::~WGraphicsEngine(), and WKernel::~WKernel().
| void WLogger::setDefaultFormat | ( | std::string | format | ) |
Set the default format used for log entries.
| format | the format string. See WLogEntry for details. |
Definition at line 101 of file WLogger.cpp.
References m_outputs.
| void WLogger::setDefaultLogLevel | ( | const LogLevel & | level | ) |
Set the default log-level used for log entries in default console-output.
| level | the log-level |
Definition at line 106 of file WLogger.cpp.
References m_outputs.
|
static |
Create the first and only instance of the logger as it is a singleton.
| output | the output stream to use |
| level | the default log level |
Definition at line 41 of file WLogger.cpp.
References WLogger().
Referenced by WHistogramBasicTest::setUp(), WDataSetScalarTest::setUp(), WDataSetDTITest::setUp(), WITKImageConversionTest::setUp(), WDataHandlerTest::setUp(), WDataSetVectorTest::setUp(), WTrackingUtilityTest::setUp(), WDataSetSingleTest::setUp(), WThreadedPerVoxelOperationTest::setUp(), WDendrogramTest::setUp(), WJoinContourTreeTest::setUp(), WModuleConnectorTest::setUp(), and WDataSetTimeSeriesTest::setUp().
| boost::signals2::connection WLogger::subscribeSignal | ( | LogEvent | event, |
| LogEntryCallback | callback | ||
| ) |
Subscribe to the specified signal.
| event | the kind of signal the callback should be used for. |
| callback | the callback. |
Definition at line 73 of file WLogger.cpp.
References AddLog, and m_addLogSignal.
|
private |
Signal called whenever a new log message arrives.
Definition at line 161 of file WLogger.h.
Referenced by addLogMessage(), and subscribeSignal().
|
private |
The list of outputs to print the messages to.
Definition at line 156 of file WLogger.h.
Referenced by addLogMessage(), addStream(), getDefaultFormat(), setDefaultFormat(), setDefaultLogLevel(), and WLogger().
1.8.1