OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
WLogger Class Reference

This class defines the interface for adding logs and managing several output streams for them. More...

#include <WLogger.h>

+ Collaboration diagram for WLogger:

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 WLoggergetLogger ()
 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...
 

Detailed Description

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.

Definition at line 46 of file WLogger.h.

Member Typedef Documentation

◆ LogEntryCallback

typedef boost::function< void ( WLogEntry& ) > WLogger::LogEntryCallback

The type for all callbacks which get a log entry as parameter.

Definition at line 125 of file WLogger.h.

◆ Outputs

The output stream list type.

Definition at line 157 of file WLogger.h.

Member Enumeration Documentation

◆ LogEvent

Types of signals supported by the logger.

Enumerator
AddLog 

for added logs

Definition at line 116 of file WLogger.h.

Constructor & Destructor Documentation

◆ ~WLogger()

WLogger::~WLogger ( )
virtual

Destructor.

Definition at line 60 of file WLogger.cpp.

◆ WLogger() [1/2]

WLogger::WLogger ( std::ostream &  output,
LogLevel  level 
)
private

Constructor.

The logger is created using the static method startup.

Parameters
outputthe stream where to print log messages to
levellogging level, i.e. verboseness

Definition at line 49 of file WLogger.cpp.

References addLogMessage(), m_outputs, and WSharedSequenceContainer< S >::push_back().

Referenced by startup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WLogger() [2/2]

WLogger::WLogger ( const WLogger )
private

We do not want a copy constructor, so we define it private.

Member Function Documentation

◆ addLogMessage()

void WLogger::addLogMessage ( std::string  message,
std::string  source = "",
LogLevel  level = LL_DEBUG 
)

Appends a log message to the logging queue.

Parameters
messagethe log entry
sourceindicates where this entry comes from
levelThe 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addStream()

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.

Note
It is not intended to allow getting streams or modifying them except you are the owner/creator.
Parameters
sthe stream to add.

Definition at line 116 of file WLogger.cpp.

References m_outputs, and WSharedSequenceContainer< S >::push_back().

Referenced by WLoggerWrapper::addFileStream().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultFormat()

std::string WLogger::getDefaultFormat ( )

Gets the default format used for log entries.

This actually returns the format of the first log stream.

Returns
format string. See WLogEntry for details.

Definition at line 111 of file WLogger.cpp.

References m_outputs.

◆ getLogger()

WLogger * WLogger::getLogger ( )
static

Returns pointer to the currently running logger instance.

Returns
pointer to 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().

+ Here is the caller graph for this function:

◆ removeStream()

void WLogger::removeStream ( WLogStream::SharedPtr  s)

Remove the given stream.

Parameters
sthe stream to remove

Definition at line 121 of file WLogger.cpp.

References m_outputs, and WSharedSequenceContainer< S >::remove().

Referenced by WLoggerWrapper::removeFileStreamNumber().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDefaultFormat()

void WLogger::setDefaultFormat ( std::string  format)

Set the default format used for log entries.

Parameters
formatthe format string. See WLogEntry for details.

Definition at line 101 of file WLogger.cpp.

References m_outputs.

◆ setDefaultLogLevel()

void WLogger::setDefaultLogLevel ( const LogLevel &  level)

Set the default log-level used for log entries in default console-output.

Parameters
levelthe log-level

Definition at line 106 of file WLogger.cpp.

References m_outputs.

Referenced by WMainWindow::handleLogLevelUpdate(), and WQtGui::run().

+ Here is the caller graph for this function:

◆ startup()

void WLogger::startup ( std::ostream &  output = std::cout,
LogLevel  level = LL_DEBUG 
)
static

◆ subscribeSignal()

boost::signals2::connection WLogger::subscribeSignal ( LogEvent  event,
LogEntryCallback  callback 
)

Subscribe to the specified signal.

Note
If you want to listen to incoming log entries, you can also utilize the WLogStream class.
Parameters
eventthe kind of signal the callback should be used for.
callbackthe callback.
Returns
the connection object. Disconnect it explicitly!

Definition at line 73 of file WLogger.cpp.

References AddLog, and m_addLogSignal.

Referenced by WQtGui::run().

+ Here is the caller graph for this function:

Member Data Documentation

◆ 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().

◆ m_outputs

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().


The documentation for this class was generated from the following files: