Bus Messages 1.0
Bus Message Serialization Library
Loading...
Searching...
No Matches
bus::BusLogStream Class Reference

Simple interface against a logging system. More...

#include <buslogstream.h>

Inheritance diagram for bus::BusLogStream:
Collaboration diagram for bus::BusLogStream:

Public Member Functions

 BusLogStream (std::source_location location, BusLogSeverity severity)
 Constructor that is a simple wrapper around an outpout stream.

Static Public Member Functions

static uint64_t ErrorCount ()
 Returns number of error messages.
static void ResetErrorCount ()
 Resets the error counter.
static void BusConsoleLogFunction (const std::source_location &location, BusLogSeverity severity, const std::string &text)
 Simple function that sends all logs to the std::cout.
static void BusNoLogFunction (const std::source_location &location, BusLogSeverity severity, const std::string &text)
 Simple function that doesn't do anything.

Static Public Attributes

static std::function< void(const std::source_location &location, BusLogSeverity severity, const std::string &text)> UserLogFunction
 The end-user should supply a function that redirect the logs.

Detailed Description

The class defines an API against a text logging system. It doesn't implement the logging system itself. Instead the end-user need to write some adpater code that redirect the messages to their logging system. The 'ihedvall/utillib' GitHub repository implements a logging system.

Constructor & Destructor Documentation

◆ BusLogStream()

bus::BusLogStream::BusLogStream ( std::source_location location,
BusLogSeverity severity )

The end-user doesn't use this class directly. Instead he/she use the log macros.

Parameters
locationSet by the macros to the current location.
severitySets the severity level (syslog severity levels).

Member Function Documentation

◆ ErrorCount()

uint64_t bus::BusLogStream::ErrorCount ( )
inlinestatic

Returns number of error messages generated. More correctly it counts all severity code large or equal to error. This is typical used in test situations.

Returns
Number of severe error logs.

Member Data Documentation

◆ UserLogFunction

std::function<void(const std::source_location& location, BusLogSeverity severity, const std::string& text)> bus::BusLogStream::UserLogFunction
static

This callback function need to be set by the end-user. If the function is used, all log messages are redirected by this function. If no function is set, no log messages are reocrded.


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