Workspace 6.21.5
Public Member Functions | List of all members
LogStream Class Referenceabstract

Abstracts away the task sending log text to a destination. More...

#include <Workspace/DataExecution/Logging/logstream.h>

Inheritance diagram for LogStream:
[legend]

Public Member Functions

virtual ~LogStream ()
 
virtual void flush ()=0
 
virtual bool isStreamOkay () const =0
 
void logText (const QString &msg, const QDateTime &timestamp)
 

Detailed Description

Each instance of this class represents a distinct logging stream. The main purpose of LogStream is to provide an alternate destination for text sent to stdout. A LogStream object is almost always used by passing it to LogManager::addStream(), since the LogManager then takes care of capturing stdout and sending it to the LogStream.

Text is sent to the stream by calling logText(). Clients can check if the stream is writable by calling isStreamOkay() and they can ensure that all data has been sent to its final destination by calling flush(). It will normally be more efficient to just let the stream object handle buffering and flushing automatically.

Constructor & Destructor Documentation

◆ ~LogStream()

~LogStream ( )
virtualdefault

Ensures that all concrete classes derived from LogStream must call Application::LogManager::getInstance().removeStream(*this); in their dtors to remove themselves from LogStream's streams list.

If the object was not added to the LogStream list, the call will have no effect and generate no error. This call has to be made in this dtor instead of the base class LogStream dtor because by the time LogStream dtor is called (and waiting for its execution) the child class has already been destroyed, which leads to a crash in the LogManager's LogThread's queue that may still be processing this stream.

Member Function Documentation

◆ flush()

virtual void flush ( )
pure virtual

Clients would not normally need to call this function, but if for some reason they want to be sure that all logged text has been sent to where it needs to go before performing some task, they can call flush(). When flush() returns, all underlying streams and buffers associated with the LogStream object will have been flushed to disk, etc.

Implemented in LogWorkflow, DefaultOutputStreamBase, LogToFile, LogToGui, QmlLogStream, and MockLogStream.

◆ isStreamOkay()

virtual bool isStreamOkay ( ) const
pure virtual
Returns
True if the stream is able to accept text for writing.

Implemented in LogWorkflow, DefaultOutputStreamBase, LogToFile, LogToGui, QmlLogStream, and MockLogStream.

◆ logText()

void logText ( const QString &  msg,
const QDateTime &  timestamp 
)
Parameters
msgThe text to be logged to this stream.m.
timestampThe timestamp when the log was handed to LogManager.