EduArt Sensor Ring Library 3.0.0
Loading...
Searching...
No Matches
Logger.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 EduArt Robotik GmbH
2
9
10#pragma once
11
12#include <functional>
13#include <sstream>
14#include <string>
15
17#include "sensorring/platform/SensorringExport.hpp"
19
20namespace eduart {
21
22namespace logger {
23
28class SENSORRING_EXPORT Logger {
29public:
31 ~Logger() = default;
32
37 static Logger* getInstance() noexcept;
38
44 subscription::Subscription subscribe(std::function<void(const LogVerbosity verbosity, const std::string& msg)> callback);
45
50 void unsubscribe(subscription::SubscriberToken token);
51
58 void log(const LogVerbosity verbosity, const std::string& msg) const;
59
66 void log(const LogVerbosity verbosity, const std::stringstream& msg) const;
67
68private:
70 Logger() = default;
71
72 subscription::Publisher<const LogVerbosity, const std::string&> _publisher;
73};
74
75} // namespace logger
76
77} // namespace eduart
Log verbosity levels for the logger.
LogVerbosity
Verbosity levels for logger output and filtering.
Definition LogVerbosity.hpp:25
Thread-safe, deadlock-free publish/subscribe template.
subscription::Subscription subscribe(std::function< void(const LogVerbosity verbosity, const std::string &msg)> callback)
Subscribe to log messages.
void log(const LogVerbosity verbosity, const std::string &msg) const
Log a message that will be relayed to all registered observers.
void unsubscribe(subscription::SubscriberToken token)
Unsubscribe from log messages.
~Logger()=default
Destructor.
static Logger * getInstance() noexcept
Get a pointer to the instance of the Logger singleton.