OpenWalnut
1.5.0dev
|
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. More... | |
Public Member Functions | |
virtual | ~WLogger () |
Destructor. More... | |
void | addStream (WLogStream::SharedPtr s) |
Adds a new stream to the logger. More... | |
void | removeStream (WLogStream::SharedPtr s) |
Remove the given stream. More... | |
void | setDefaultFormat (std::string format) |
Set the default format used for log entries. More... | |
void | setDefaultLogLevel (const LogLevel &level) |
Set the default log-level used for log entries in default console-output. More... | |
std::string | getDefaultFormat () |
Gets the default format used for log entries. More... | |
void | addLogMessage (std::string message, std::string source="", LogLevel level=LL_DEBUG) |
Appends a log message to the logging queue. More... | |
boost::signals2::connection | subscribeSignal (LogEvent event, LogEntryCallback callback) |
Subscribe to the specified signal. More... | |
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. More... | |
static WLogger * | getLogger () |
Returns pointer to the currently running logger instance. More... | |
Private Types | |
typedef WSharedSequenceContainer< std::vector< WLogStream::SharedPtr > > | Outputs |
The output stream list type. More... | |
Private Member Functions | |
WLogger (std::ostream &output, LogLevel level) | |
Constructor. More... | |
WLogger (const WLogger &) | |
We do not want a copy constructor, so we define it private. More... | |
Private Attributes | |
Outputs | m_outputs |
The list of outputs to print the messages to. More... | |
boost::signals2::signal< void(WLogEntry &) > | m_addLogSignal |
Signal called whenever a new log message arrives. More... | |
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(), WMainWindow::autoAdd(), WDataHandler::clear(), WModuleConnector::connect(), WPropertyWidget::construct(), WMPaintTexture::createROI(), WLoggerWrapper::debug(), WQtControlPanel::deleteModule(), WModuleConnector::disconnect(), WLoggerWrapper::error(), WQtControlPanel::event(), WQtNetworkEditor::event(), WReaderEEG::extractElectrodePositions(), WKernel::finalize(), WLoggerWrapper::info(), WModuleFactory::load(), WModuleLoader::load(), WMDistanceMap::moduleMain(), WGraphicsEngine::notifyStop(), WMTeemGlyphs::GlyphGeneration::operator()(), WMeshReaderBrainVISA::operator()(), WMeshReaderDIP::operator()(), WMeshReaderFiberNavigator::operator()(), WMeshReaderVTK::operator()(), WGEShader::processShaderRecursive(), WMReadAmiraMesh::readAmiraMesh(), WMReadRawData::readDataTyped(), WGEShader::reloadShader(), WModuleContainer::remove(), WDataHandler::removeSubject(), WMWriteMesh::saveJson(), WMWriteTracts::saveJson(), WMWriteTracts::saveJson2(), WMWriteTracts::saveJsonTriangles(), WMWriteMesh::saveSTL(), WMWriteField::saveVTKASCII(), WMWriteMesh::saveVTKASCII(), WQtGLWidget::setCameraManipulator(), WGraphicsEngine::setMultiThreadedViews(), WModuleContainer::stop(), WThreadedRunner::threadMain(), WGraphicsEngine::threadMain(), WKernel::threadMain(), WModule::threadMain(), WGraphicsEngine::waitForStartupComplete(), WLoggerWrapper::warning(), 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().
Referenced by WLoggerWrapper::addFileStream().
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(), WMainWindow::autoAdd(), WDataHandler::clear(), WModuleConnector::connect(), WPropertyWidget::construct(), WMPaintTexture::createROI(), WQtControlPanel::deleteModule(), WModuleConnector::disconnect(), WQtControlPanel::event(), WQtNetworkEditor::event(), WReaderEEG::extractElectrodePositions(), WKernel::finalize(), WMainWindow::handleLogLevelUpdate(), WModuleFactory::load(), WModuleLoader::load(), WMDistanceMap::moduleMain(), WGraphicsEngine::notifyStop(), WMTeemGlyphs::GlyphGeneration::operator()(), WMeshReaderBrainVISA::operator()(), WMeshReaderDIP::operator()(), WMeshReaderFiberNavigator::operator()(), WMeshReaderVTK::operator()(), WGEShader::processShaderRecursive(), WMReadAmiraMesh::readAmiraMesh(), WMReadRawData::readDataTyped(), WGEShader::reloadShader(), WModuleContainer::remove(), WDataHandler::removeSubject(), WQtGui::run(), WMWriteMesh::saveJson(), WMWriteTracts::saveJson(), WMWriteTracts::saveJson2(), WMWriteTracts::saveJsonTriangles(), WMWriteMesh::saveSTL(), WMWriteField::saveVTKASCII(), WMWriteMesh::saveVTKASCII(), WQtGLWidget::setCameraManipulator(), WGraphicsEngine::setMultiThreadedViews(), WModuleContainer::stop(), WThreadedRunner::threadMain(), WGraphicsEngine::threadMain(), WKernel::threadMain(), WModule::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().
Referenced by WLoggerWrapper::removeFileStreamNumber().
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.
Referenced by WMainWindow::handleLogLevelUpdate(), and WQtGui::run().
|
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 WHistogram2DTest::setUp(), WHistogramBasicTest::setUp(), WJoinContourTreeTest::setUp(), WDataHandlerTest::setUp(), WDataSetDTITest::setUp(), WDataSetScalarTest::setUp(), WDataSetTimeSeriesTest::setUp(), WITKImageConversionTest::setUp(), WThreadedPerVoxelOperationTest::setUp(), WTrackingUtilityTest::setUp(), WModuleConnectorTest::setUp(), WMPointConnectorTest::setUp(), WMWriteMeshTest::setUp(), WDendrogramTest::setUp(), WDataSetSingleTest::setUp(), WDataSetVectorTest::setUp(), WReaderNIfTITest::setUp(), WBresenhamTest::setUp(), and WBresenhamDBLTest::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.
Referenced by WQtGui::run().
|
private |
Signal called whenever a new log message arrives.
Definition at line 167 of file WLogger.h.
Referenced by addLogMessage(), and subscribeSignal().
|
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().