EduArt Sensor Ring Library 4.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 sensorring {
23
24namespace logger {
25
30class SENSORRING_EXPORT Logger {
31public:
33 ~Logger() = default;
34
39 static Logger* getInstance() noexcept;
40
46 subscription::Subscription subscribe(std::function<void(const LogVerbosity verbosity, const std::string& msg)> callback);
47
52 void unsubscribe(subscription::SubscriberToken token);
53
60 void log(const LogVerbosity verbosity, const std::string& msg) const;
61
68 void log(const LogVerbosity verbosity, const std::stringstream& msg) const;
69
70private:
72 Logger() = default;
73
74 subscription::Publisher<const LogVerbosity, const std::string&> _publisher;
75};
76
77} // namespace logger
78
79} // namespace sensorring
80
81} // namespace eduart
Log verbosity levels for the logger.
LogVerbosity
Verbosity levels for logger output and filtering.
Definition LogVerbosity.hpp:27
Thread-safe, deadlock-free publish/subscribe template.
void unsubscribe(subscription::SubscriberToken token)
Unsubscribe from log messages.
subscription::Subscription subscribe(std::function< void(const LogVerbosity verbosity, const std::string &msg)> callback)
Subscribe to log messages.
static Logger * getInstance() noexcept
Get a pointer to the instance of the Logger singleton.
void log(const LogVerbosity verbosity, const std::string &msg) const
Log a message that will be relayed to all registered observers.