Default context for printing and collecting statistics.
More...
#include <ContextBase.hpp>
|
| ContextHandle * | createHandle (const std::string &name) noexcept |
| | Creates a new named handle to the active context. More...
|
| |
|
const char * | loglevelToStr (uint8_t level) const noexcept |
| |
|
const fmt::text_style & | getStyleForLevel (uint8_t level) const noexcept |
| |
|
void | printStatistics () noexcept |
| |
|
virtual void | handleLogMsg (const std::string &sender, uint8_t level, const std::string &message) noexcept |
| |
|
| static void | registerContext (ContextBase *context) |
| | Registers a context for the whole application. More...
|
| |
|
static std::mutex & | _getMutex () noexcept |
| |
|
static std::unique_ptr< ContextBase > & | _getActiveRef () noexcept |
| |
| static ContextBase & | getActive () noexcept |
| | Returns active Context. More...
|
| |
|
static void | logDebug (const std::string &message, uint64_t token=0) |
| | Sends log message with level DEBUG from anonymous source.
|
| |
|
static void | logInfo (const std::string &message, uint64_t token=0) |
| | Sends log message with level DEBUG from anonymous source.
|
| |
|
static void | logWarning (const std::string &message, uint64_t token=0) |
| | Sends log message with level DEBUG from anonymous source.
|
| |
|
static void | logError (const std::string &message, uint64_t token=0) |
| | Sends log message with level DEBUG from anonymous source.
|
| |
|
static void | logCritical (const std::string &message, uint64_t token=0) |
| | Sends log message with level DEBUG from anonymous source.
|
| |
|
|
bool | useStyles {true} |
| |
| fmt::text_style | styles [6] |
| |
|
std::vector< std::unique_ptr< ContextHandle > > | _handles |
| |
Default context for printing and collecting statistics.
◆ createHandle()
| ContextHandle * pottu::ContextBase::createHandle |
( |
const std::string & |
name | ) |
|
|
inlinenoexcept |
Creates a new named handle to the active context.
Use ContextBase::getActive().createHandle(name) to create a new handle.
◆ getActive()
Returns active Context.
This will always return a valid context. If no user derived context has been registered then this call will instantiate the singleton context with ContextBase context. The method locks a mutex so not to be used in tight loops.
◆ registerContext()
| static void pottu::ContextBase::registerContext |
( |
ContextBase * |
context | ) |
|
|
inlinestatic |
Registers a context for the whole application.
This can be run only once! The context will be destructed at the end of the program. Will throw if context is already set. Note that call to createHandle() or getActive() will create a default context (ContextBase) so user defined context must be registered before any call to createHandle().
◆ styles
| fmt::text_style pottu::ContextBase::styles[6] |
Initial value:= {
{fg(fmt::color::gray)},
{fg(fmt::color::gray)},
{},
{fmt::emphasis::bold | bg(fmt::color::black) | fg(fmt::color::yellow)},
{fg(fmt::color::red)},
{fmt::emphasis::bold | fg(fmt::color::red)}
}
The documentation for this struct was generated from the following file: