Cogs.Core
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Cogs::Logging::ConsoleLogger Class Reference

Console logger that supports splitting log lines between stdout and stderr according to severity. More...

#include <ConsoleLogger.h>

Inheritance diagram for Cogs::Logging::ConsoleLogger:
Cogs::Logging::ThrottledConsumer Cogs::Logging::Consumer

Public Member Functions

void setUseColor (bool set_use_color)
 
- Public Member Functions inherited from Cogs::Logging::ThrottledConsumer
virtual void consumeMessage (const char *source, Category category, uint32_t errorNumber, const char *message, const char *filename, int lineNumber) override
 Consumes a message being sent through the logging system.
 
void flush (bool flushAll=true)
 Flushes some or all messages currently queued and awaiting a suitable time to be output.
 
- Public Member Functions inherited from Cogs::Logging::Consumer
 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 ConsoleLoggerinstance ()
 
static void initialize ()
 
- Static Public Member Functions inherited from Cogs::Logging::ThrottledConsumer
static void setEnabled (bool enable)
 Enables or disables throttling of messages.
 
- Static Public Member Functions inherited from Cogs::Logging::Consumer
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)
 

Private Member Functions

virtual void outputMessage (const std::string &prefix, const Message &message) override
 

Private Attributes

bool use_color = true
 

Additional Inherited Members

- Protected Attributes inherited from Cogs::Logging::Consumer
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.
 

Detailed Description

Console logger that supports splitting log lines between stdout and stderr according to severity.

By default, all logging goes to stderr, but that behaviour can be overridden by calling setStderrThreshold.

ConsoleLogger is a ThrottledConsumer. It will only receive non-spammy messages. Throttled messages will be periodically output with a counter showing how many duplicates were suppressed.

Definition at line 15 of file ConsoleLogger.h.

Constructor & Destructor Documentation

◆ ConsoleLogger()

Cogs::Logging::ConsoleLogger::ConsoleLogger ( )

Definition at line 13 of file ConsoleLogger.cpp.

◆ ~ConsoleLogger()

Cogs::Logging::ConsoleLogger::~ConsoleLogger ( )
override

Definition at line 21 of file ConsoleLogger.cpp.

Member Function Documentation

◆ initialize()

static void Cogs::Logging::ConsoleLogger::initialize ( )
inlinestatic

Definition at line 22 of file ConsoleLogger.h.

◆ instance()

Cogs::Logging::ConsoleLogger & Cogs::Logging::ConsoleLogger::instance ( )
static

Definition at line 26 of file ConsoleLogger.cpp.

◆ outputMessage()

void Cogs::Logging::ConsoleLogger::outputMessage ( const std::string &  prefix,
const Message message 
)
overrideprivatevirtual

Implements Cogs::Logging::ThrottledConsumer.

Definition at line 33 of file ConsoleLogger.cpp.

◆ setUseColor()

void Cogs::Logging::ConsoleLogger::setUseColor ( bool  set_use_color)
inline

Definition at line 23 of file ConsoleLogger.h.

Member Data Documentation

◆ use_color

bool Cogs::Logging::ConsoleLogger::use_color = true
private

Definition at line 26 of file ConsoleLogger.h.


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