Cogs.Core
|
ThrottledConsumer is a log message consumer that attempts to throttle messages to reduce log spam. More...
#include <ThrottledConsumer.h>
Classes | |
struct | Message |
Public Member Functions | |
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. | |
![]() | |
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 | setEnabled (bool enable) |
Enables or disables throttling of messages. | |
![]() | |
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 Types | |
using | MessageMap = std::map< size_t, Message > |
Private Member Functions | |
virtual void | outputMessage (const std::string &prefix, const Message &message)=0 |
Private Attributes | |
MessageMap | messages |
Mutex | messagesMutex |
Additional Inherited Members | |
![]() | |
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. | |
ThrottledConsumer is a log message consumer that attempts to throttle messages to reduce log spam.
Derived implementations (I.e., consumers that want throttled messages) should override outputMessage and deal with the message data as required.
Definition at line 17 of file ThrottledConsumer.h.
|
private |
Definition at line 35 of file ThrottledConsumer.h.
|
overridevirtual |
Consumes a message being sent through the logging system.
This throttling consumer may prevent the message from being output immediately to reduce spam from overly enthusiastic systems. *============================================================================================
Implements Cogs::Logging::Consumer.
Definition at line 26 of file ThrottledConsumer.cpp.
References Cogs::Logging::ThrottledConsumer::Message::category, Cogs::Logging::ThrottledConsumer::Message::count, Cogs::Logging::ThrottledConsumer::Message::file, Cogs::hashSequence(), Cogs::Logging::ThrottledConsumer::Message::line, Cogs::Logging::ThrottledConsumer::Message::message, Cogs::Logging::ThrottledConsumer::Message::outputTime, and Cogs::Logging::ThrottledConsumer::Message::source.
void Cogs::Logging::ThrottledConsumer::flush | ( | bool | flushAll = true | ) |
Flushes some or all messages currently queued and awaiting a suitable time to be output.
*============================================================================================
Definition at line 48 of file ThrottledConsumer.cpp.
References Cogs::Logging::ThrottledConsumer::Message::count, and Cogs::Logging::ThrottledConsumer::Message::outputTime.
|
static |
Enables or disables throttling of messages.
This setting will be applied to all throttled consumers. *============================================================================================
Definition at line 16 of file ThrottledConsumer.cpp.
|
private |
Definition at line 37 of file ThrottledConsumer.h.
|
private |
Definition at line 38 of file ThrottledConsumer.h.