Zappy Server
C++ game server: world, rules, scheduler, network
Loading...
Searching...
No Matches
Logger.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string_view>
5
7
17class Logger {
18 public:
19 explicit Logger(LogLevel threshold = LogLevel::Debug);
20
21 void setSink(std::unique_ptr<ILogSink> sink);
22 void setThreshold(LogLevel threshold) { _threshold = threshold; }
23
24 void debug(std::string_view component, std::string_view msg);
25 void info(std::string_view component, std::string_view msg);
26 void warn(std::string_view component, std::string_view msg);
27 void error(std::string_view component, std::string_view msg);
28
29 private:
30 void _log(LogLevel level, std::string_view component, std::string_view msg);
31
32 std::unique_ptr<ILogSink> _sink;
34};
LogLevel
Definition ILogSink.hpp:5
Logging facade: formats [time] [LEVEL] [component] message, filters by level, and forwards to a singl...
Definition Logger.hpp:17
void info(std::string_view component, std::string_view msg)
Definition Logger.cpp:55
void setThreshold(LogLevel threshold)
Definition Logger.hpp:22
void debug(std::string_view component, std::string_view msg)
Definition Logger.cpp:50
void error(std::string_view component, std::string_view msg)
Definition Logger.cpp:65
void setSink(std::unique_ptr< ILogSink > sink)
Definition Logger.cpp:39
void _log(LogLevel level, std::string_view component, std::string_view msg)
Definition Logger.cpp:41
std::unique_ptr< ILogSink > _sink
Definition Logger.hpp:32
LogLevel _threshold
Definition Logger.hpp:33
void warn(std::string_view component, std::string_view msg)
Definition Logger.cpp:60