Workspace 6.21.5
Public Types | Public Member Functions | Public Attributes | List of all members
LogManagerImplThreaded Class Reference

Implementation of the LogManager that supports logging from mulitiple threads simultaneously. More...

#include <Workspace/Application/logmanagerimplthreaded.h>

Inherits LogManagerImpl.

Public Types

using FilterRegistry = QMap< const QThread *, FilterSet >
 
using FilterSet = QSet< DataExecution::LogStreamFilter >
 

Public Member Functions

 LogManagerImplThreaded ()
 
 ~LogManagerImplThreaded ()
 
bool addMessageCategory (const LogManager::MessageCategory &category) override
 
void addStream (DataExecution::LogStream &logStream) override
 
void cleanup () override
 
bool filterMessage (const QString &msg, const QString &category, const QThread *currThread, const QThread *parentThread) override
 
void flush () override
 
void flushAsync () override
 
const LogManager::MessageCategorygetMessageCategory (const QString &category) const override
 
QList< const DataExecution::LogStream * > getStreams () const override
 
bool hasMessageCategory (const QString &category) const override
 
bool installFilter (const DataExecution::LogStreamFilter &filter) override
 
bool isMessageCategoryEnabled (const QString &category) const override
 
void logText (const QString &msg, const QString &category) override
 
void logTextAsync (const QString &msg, const QString &category) override
 
bool removeFilter (const DataExecution::LogStreamFilter &filter) override
 
bool removeStream (DataExecution::LogStream &logStream) override
 
void setDefaultMessageCategory (const QString &category) override
 
void setMessageCategoryEnabled (const QString &category, bool enabled) override
 

Public Attributes

std::mutex filterAddRemoveMutex_
 
FilterRegistry filters_
 
std::atomic_bool haveFilters_ {false}
 

Detailed Description

This is the implementation of the LogManager that will be used if being used in a QCoreApplication. It uses a threadsafe queue to manage all requests for updates to the log, including messages or addition / removal of log streams.

See also
LogManagerImplUnthreaded

Member Typedef Documentation

◆ FilterRegistry

using FilterRegistry = QMap<const QThread*, FilterSet>

◆ FilterSet

Constructor & Destructor Documentation

◆ LogManagerImplThreaded()

◆ ~LogManagerImplThreaded()

~LogManagerImplThreaded ( )
default

Member Function Documentation

◆ addMessageCategory()

bool addMessageCategory ( const LogManager::MessageCategory category)
override

◆ addStream()

void addStream ( DataExecution::LogStream logStream)
override

◆ cleanup()

void cleanup ( )
override

◆ filterMessage()

bool filterMessage ( const QString &  msg,
const QString &  category,
const QThread *  currThread,
const QThread *  parentThread 
)
override
Returns
true if the message was accepted by the various filters, false if it was rejected and should therefore not be displayed.
Note
Only invoked from within the logging (rwThread_) thread.

◆ flush()

void flush ( )
override

Flush the log (synchronously).

◆ flushAsync()

void flushAsync ( )
override

Flush the log (asynchronously).

◆ getMessageCategory()

const LogManager::MessageCategory * getMessageCategory ( const QString &  categoryName) const
override
Parameters
categoryNameThe name of the category to retrieve.
Returns
A pointer to the category with the specified name, 0 if a category with this name does not exist.

◆ getStreams()

QList< const DataExecution::LogStream * > getStreams ( ) const
override

Retrieves all streams

◆ hasMessageCategory()

bool hasMessageCategory ( const QString &  category) const
override
Parameters
categoryThe category we are testing.
Returns
true if the category exists, false otherwise

Checks whether the log manager has knowledge of a specific category.

See also
logText()

◆ installFilter()

bool installFilter ( const DataExecution::LogStreamFilter filter)
override
Parameters
filterThe filter to install

Installs a message filter.

Returns
true if the filter was installed correctly, false otherwise.

◆ isMessageCategoryEnabled()

bool isMessageCategoryEnabled ( const QString &  category) const
override
Parameters
categoryThe category to check
See also
logText() setMessageCategoryEnabled()

◆ logText()

void logText ( const QString &  msg,
const QString &  category 
)
override

Synchronous version of the logText function.

◆ logTextAsync()

void logTextAsync ( const QString &  msg,
const QString &  category 
)
override

Asynchronous version of the logText function.

◆ removeFilter()

bool removeFilter ( const DataExecution::LogStreamFilter filter)
override

◆ removeStream()

bool removeStream ( DataExecution::LogStream logStream)
override

Removes a stream (synchronously).

◆ setDefaultMessageCategory()

void setDefaultMessageCategory ( const QString &  category)
override
Parameters
categoryThe message category to set as a default. By default, this is not used, so all messages will be logged with no category.

◆ setMessageCategoryEnabled()

void setMessageCategoryEnabled ( const QString &  category,
bool  enabled 
)
override
Parameters
categoryThe category to enable / disable
enabledThe desired enabled state of the category

Enables / disables a specific category name in the LogManager. The LogManager uses categories with the LogText call to "tag" specific text with a certain category. By disabling category, log messages associated with that category will not be displayed.

See also
logText() isMessageCategoryEnabled()

Member Data Documentation

◆ filterAddRemoveMutex_

std::mutex filterAddRemoveMutex_

◆ filters_

FilterRegistry filters_

◆ haveFilters_

std::atomic_bool haveFilters_ {false}