20#include <source_location>
45static std::string_view BusLogServerityToText(
BusLogSeverity severity);
48#define BUS_TRACE() BusLogStream(std::source_location::current(), BusLogSeverity::kTrace)
51#define BUS_DEBUG() BusLogStream(std::source_location::current(), BusLogSeverity::kDebug)
54#define BUS_INFO() BusLogStream(std::source_location::current(), BusLogSeverity::kInfo)
57#define BUS_NOTICE() BusLogStream(std::source_location::current(), BusLogSeverity::kNotice)
60#define BUS_WARNING() BusLogStream(std::source_location::current(), BusLogSeverity::kWarning)
63#define BUS_ERROR() BusLogStream(std::source_location::current(), BusLogSeverity::kError)
66#define BUS_CRITICAL() BusLogStream(std::source_location::current(), BusLogSeverity::kCritical)
69#define BUS_ALERT() BusLogStream(std::source_location::current(), BusLogSeverity::kAlert)
72#define BUS_EMERGENCY() BusLogStream(std::source_location::current(), BusLogSeverity::kEmergency)
82class BusLogStream :
public std::ostringstream {
84 BusLogStream() =
delete;
93 ~BusLogStream()
override;
102 static std::function<void(
const std::source_location& location,
127 std::source_location location_;
128 static std::atomic<uint64_t> error_count_;
130 static void LogString(
const std::source_location& location,
132 const std::string& text);
static void BusConsoleLogFunction(const std::source_location &location, BusLogSeverity severity, const std::string &text)
Simple function that sends all logs to the std::cout.
BusLogStream(std::source_location location, BusLogSeverity severity)
Constructor that is a simple wrapper around an outpout stream.
static void BusNoLogFunction(const std::source_location &location, BusLogSeverity severity, const std::string &text)
Simple function that doesn't do anything.
static void ResetErrorCount()
Resets the error counter.
Definition buslogstream.h:117
static uint64_t ErrorCount()
Returns number of error messages.
Definition buslogstream.h:114
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.
Definition buslogstream.h:104
Main namespace for the MDF library.
Definition buslogstream.h:24
BusLogSeverity
Defines the log severity level.
Definition buslogstream.h:32
@ kInfo
Informational message.
Definition buslogstream.h:35
@ kEmergency
Fatal error message.
Definition buslogstream.h:41
@ kCritical
Critical message (device error)
Definition buslogstream.h:39
@ kNotice
Notice message. Notify the user.
Definition buslogstream.h:36
@ kDebug
Debug message.
Definition buslogstream.h:34
@ kAlert
Alert or alarm message.
Definition buslogstream.h:40
@ kError
Error message.
Definition buslogstream.h:38
@ kWarning
Warning message.
Definition buslogstream.h:37
@ kTrace
Trace or listen message.
Definition buslogstream.h:33