|
OpenWalnut 1.3.1
|
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 | removeStream (WLogStream::SharedPtr s) |
| Remove the given stream. | |
| 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 |
typedef WSharedSequenceContainer< std::vector< WLogStream::SharedPtr > > WLogger::Outputs [private] |
| enum WLogger::LogEvent |
| WLogger::~WLogger | ( | ) | [virtual] |
Destructor.
Definition at line 60 of file WLogger.cpp.
| WLogger::WLogger | ( | std::ostream & | output, |
| LogLevel | level | ||
| ) | [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().
| WLogger::WLogger | ( | const WLogger & | ) | [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(), WModuleLoader::load(), WModuleFactory::load(), WGraphicsEngine::notifyStop(), WGEShader::processShaderRecursive(), WGEShader::reloadShader(), WModuleContainer::remove(), WDataHandler::removeSubject(), WGraphicsEngine::setMultiThreadedViews(), WModuleContainer::stop(), WThreadedRunner::threadMain(), WModule::threadMain(), WKernel::threadMain(), WGraphicsEngine::threadMain(), WGraphicsEngine::waitForStartupComplete(), 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.
| WLogger * WLogger::getLogger | ( | ) | [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(), WModuleLoader::load(), WModuleFactory::load(), WGraphicsEngine::notifyStop(), WGEShader::processShaderRecursive(), WGEShader::reloadShader(), WModuleContainer::remove(), WDataHandler::removeSubject(), WGraphicsEngine::setMultiThreadedViews(), WModuleContainer::stop(), WThreadedRunner::threadMain(), WModule::threadMain(), WKernel::threadMain(), WGraphicsEngine::threadMain(), WGraphicsEngine::waitForStartupComplete(), WDataHandler::WDataHandler(), WGEScene::WGEScene(), WGraphicsEngine::WGraphicsEngine(), WKernel::WKernel(), WModuleContainer::WModuleContainer(), wlog::WStreamedLogger::Buffer::~Buffer(), WGEScene::~WGEScene(), WGraphicsEngine::~WGraphicsEngine(), and WKernel::~WKernel().
| void WLogger::removeStream | ( | WLogStream::SharedPtr | s | ) |
Remove the given stream.
| s | the stream to remove |
Definition at line 121 of file WLogger.cpp.
References m_outputs, and WSharedSequenceContainer< S >::remove().
| 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.
| void WLogger::startup | ( | std::ostream & | output = std::cout, |
| LogLevel | level = LL_DEBUG |
||
| ) | [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 WTrackingUtilityTest::setUp(), WThreadedPerVoxelOperationTest::setUp(), WModuleConnectorTest::setUp(), WJoinContourTreeTest::setUp(), WITKImageConversionTest::setUp(), WHistogramBasicTest::setUp(), WDendrogramTest::setUp(), WDataSetVectorTest::setUp(), WDataSetTimeSeriesTest::setUp(), WDataSetSingleTest::setUp(), WDataSetScalarTest::setUp(), WDataSetDTITest::setUp(), and WDataHandlerTest::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.
boost::signals2::signal< void( WLogEntry& ) > WLogger::m_addLogSignal [private] |
Signal called whenever a new log message arrives.
Definition at line 167 of file WLogger.h.
Referenced by addLogMessage(), and subscribeSignal().
Outputs WLogger::m_outputs [private] |
The list of outputs to print the messages to.
Definition at line 162 of file WLogger.h.
Referenced by addLogMessage(), addStream(), getDefaultFormat(), removeStream(), setDefaultFormat(), setDefaultLogLevel(), and WLogger().
1.7.4