Cogs.Core
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
Cogs::Logging::Consumer Class Referenceabstract

Consumer is the base class for objects that want to consume log messages through the LogManager. More...

#include <Consumer.h>

Inheritance diagram for Cogs::Logging::Consumer:
Cogs::Logging::FileLogger Cogs::Logging::RedirectedLogger Cogs::Logging::StructuredLogger Cogs::Logging::ThrottledConsumer Cogs::Logging::ConsoleLogger

Public Member Functions

 Consumer ()
 Constructs a new Consumer instance.
 
virtual ~Consumer ()
 Unregisters this consumer from the LogManager and destroys this instance.
 
virtual void consumeMessage (const char *source, Category category, uint32_t errorNumber, const char *message, const char *filename, int lineNumber)=0
 
Category getMinimumCategory () const
 
void setMinimumCategory (Category category)
 Set the minimum category level of messages that this consumer will output.
 
void enableFilenames (bool enable)
 

Static Public Member Functions

static void setDefaultMinimumCategory (Category category)
 Sets the default minimum category for all future consumers.
 
static const char * getCategoryName (Category category)
 Retrieves a human-friendly name for the given category level.
 
static const char * getCategoryNameColor (Category category)
 

Protected Attributes

Mutex mutex
 Mutex available for implementations to use if needed.
 
bool outputFilenames = false
 Flag controlling whether or not to include the filenames for message sources.
 

Private Attributes

Category minimumCategory
 

Static Private Attributes

static Category defaultMinimumCategory = Category::Trace
 

Detailed Description

Consumer is the base class for objects that want to consume log messages through the LogManager.

Consumer implementations should override consumeMessage (which will be called from any thread) and deal with the incoming messages as they see fit.

Messages can be filtered by calling setMinimumCategory at any time, or by calling setDefaultMinimumCategory prior to consumer construction.

Definition at line 18 of file Consumer.h.

Constructor & Destructor Documentation

◆ Consumer()

Cogs::Logging::Consumer::Consumer ( )

Constructs a new Consumer instance.

Consumers register themselves automatically with the LogManager system and will begin receiving messages almost immediately. *============================================================================================

Definition at line 13 of file Consumer.cpp.

References Cogs::Logging::registerConsumer(), and setMinimumCategory().

◆ ~Consumer()

Cogs::Logging::Consumer::~Consumer ( )
virtual

Unregisters this consumer from the LogManager and destroys this instance.

*============================================================================================

Definition at line 21 of file Consumer.cpp.

References Cogs::Logging::unregisterConsumer(), and Cogs::Logging::updateMinimumCategory().

Member Function Documentation

◆ consumeMessage()

virtual void Cogs::Logging::Consumer::consumeMessage ( const char *  source,
Category  category,
uint32_t  errorNumber,
const char *  message,
const char *  filename,
int  lineNumber 
)
pure virtual

◆ enableFilenames()

void Cogs::Logging::Consumer::enableFilenames ( bool  enable)
inline

Definition at line 28 of file Consumer.h.

◆ getCategoryName()

const char * Cogs::Logging::Consumer::getCategoryName ( Category  category)
static

Retrieves a human-friendly name for the given category level.

*============================================================================================

Definition at line 46 of file Consumer.cpp.

◆ getCategoryNameColor()

const char * Cogs::Logging::Consumer::getCategoryNameColor ( Category  category)
static

Definition at line 59 of file Consumer.cpp.

◆ getMinimumCategory()

Category Cogs::Logging::Consumer::getMinimumCategory ( ) const
inline

Definition at line 25 of file Consumer.h.

◆ setDefaultMinimumCategory()

void Cogs::Logging::Consumer::setDefaultMinimumCategory ( Category  category)
static

Sets the default minimum category for all future consumers.

Set the default minimum category level of all consumers created after this call.

*============================================================================================

Definition at line 39 of file Consumer.cpp.

◆ setMinimumCategory()

void Cogs::Logging::Consumer::setMinimumCategory ( Category  category)

Set the minimum category level of messages that this consumer will output.

The lower the category value, the more noisy the log output will become. *============================================================================================

Definition at line 31 of file Consumer.cpp.

References Cogs::Logging::updateMinimumCategory().

Referenced by Consumer().

Member Data Documentation

◆ defaultMinimumCategory

Cogs::Logging::Category Cogs::Logging::Consumer::defaultMinimumCategory = Category::Trace
staticprivate

Definition at line 43 of file Consumer.h.

◆ minimumCategory

Category Cogs::Logging::Consumer::minimumCategory
private

Definition at line 42 of file Consumer.h.

◆ mutex

Mutex Cogs::Logging::Consumer::mutex
protected

Mutex available for implementations to use if needed.

Definition at line 38 of file Consumer.h.

◆ outputFilenames

bool Cogs::Logging::Consumer::outputFilenames = false
protected

Flag controlling whether or not to include the filenames for message sources.

Definition at line 39 of file Consumer.h.


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