5#include <aegis2d/core/export.hpp>
56 [[nodiscard]]
bool enabled(
LogLevel level) const noexcept;
60 void set_console(
bool enabled);
65 bool open_file(const
std::filesystem::path& path);
79 template <typename... Args>
80 void log(
LogLevel level,
std::format_string<Args...> format, Args&&... args) {
82 write(level, std::format(format, std::forward<Args>(args)...));
87 std::atomic<LogLevel> level_{LogLevel::Info};
96template <
typename... Args>
97void log_debug(std::format_string<Args...> format, Args&&... args) {
104template <
typename... Args>
105void log_info(std::format_string<Args...> format, Args&&... args) {
112template <
typename... Args>
113void log_warn(std::format_string<Args...> format, Args&&... args) {
120template <
typename... Args>
121void log_error(std::format_string<Args...> format, Args&&... args) {
Writes timestamped messages to the console (std::clog) and to an optional file.
Definition log.hpp:31
Logger & operator=(Logger &&)=delete
void log(LogLevel level, std::format_string< Args... > format, Args &&... args)
Formats and writes a message if its level is enabled.
Definition log.hpp:80
Logger()=default
Creates a logger at level Info, writing to the console only.
Logger & operator=(const Logger &)=delete
LogLevel level() const noexcept
Current minimum level.
void set_level(LogLevel level) noexcept
Sets the minimum level a message needs to be written.
static Logger & global()
Process-wide logger used by log_debug(), log_info(), log_warn() and log_error().
Logger(const Logger &)=delete
Logging, time, main loop, events and configuration shared by client and server.
Definition clock.hpp:11
void log_warn(std::format_string< Args... > format, Args &&... args)
Logs a Warn message with the global logger.
Definition log.hpp:113
void log_info(std::format_string< Args... > format, Args &&... args)
Logs an Info message with the global logger.
Definition log.hpp:105
LogLevel
Severity of a log message, from the most verbose to the most severe.
Definition log.hpp:20
void log_error(std::format_string< Args... > format, Args &&... args)
Logs an Error message with the global logger.
Definition log.hpp:121
std::string_view to_string(VarResult result) noexcept
Sentence for a VarResult, as a console shows it.
void log_debug(std::format_string< Args... > format, Args &&... args)
Logs a Debug message with the global logger.
Definition log.hpp:97
Definition endpoint.hpp:85