Cogs.Core
Consumer.cpp
1#include "Consumer.h"
2
3#include "LogManager.h"
4
5Cogs::Logging::Category Cogs::Logging::Consumer::defaultMinimumCategory = Category::Trace;
6
14 registerConsumer(this);
15 setMinimumCategory(defaultMinimumCategory);
16}
17
24}
25
32 minimumCategory = category;
34}
35
40 defaultMinimumCategory = category;
41}
42
47 constexpr const char* categoryNames[] = {
48 "Trace",
49 "Debug",
50 "Info",
51 "Warning",
52 "Error",
53 "Fatal"
54 };
55
56 return categoryNames[static_cast<int>(category)];
57}
58
59const char* Cogs::Logging::Consumer::getCategoryNameColor(Category category) {
60 constexpr const char* categoryNames[] = {
61 "Trace",
62 "Debug",
63 "Info",
64 "\033[33mWarning\033[0m",
65 "\033[31mError\033[0m",
66 "\033[31mFatal\033[0m"
67 };
68
69 return categoryNames[static_cast<int>(category)];
70}
static const char * getCategoryName(Category category)
Retrieves a human-friendly name for the given category level.
Definition: Consumer.cpp:46
virtual ~Consumer()
Unregisters this consumer from the LogManager and destroys this instance.
Definition: Consumer.cpp:21
void setMinimumCategory(Category category)
Set the minimum category level of messages that this consumer will output.
Definition: Consumer.cpp:31
static void setDefaultMinimumCategory(Category category)
Sets the default minimum category for all future consumers.
Definition: Consumer.cpp:39
Consumer()
Constructs a new Consumer instance.
Definition: Consumer.cpp:13
void COGSFOUNDATION_API registerConsumer(Consumer *consumer)
Registers the specified consumer with the LogManager.
Definition: LogManager.cpp:271
Category
Logging categories used to filter log messages.
Definition: LogManager.h:31
void updateMinimumCategory()
Internal.
Definition: LogManager.cpp:232
void COGSFOUNDATION_API unregisterConsumer(Consumer *consumer)
Removes the specified consumer from the LogManager.
Definition: LogManager.cpp:277