ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1
8
9#ifndef ASW_LOG_H
10#define ASW_LOG_H
11
12#include <format>
13#include <iostream>
14#include <string>
15
16namespace asw::log {
17
19enum class Level { DEBUG, INFO, WARN, ERROR };
20
26void log_message(Level level, const std::string& message);
27
32void set_level(Level level);
33
38void set_output(std::ostream& stream);
39
44void debug(const std::string& message);
45
51template <typename... Args> void debug(std::format_string<Args...> format, Args&&... args)
52{
53 debug(std::format(format, std::forward<Args>(args)...));
54}
55
60void info(const std::string& message);
61
67template <typename... Args> void info(std::format_string<Args...> format, Args&&... args)
68{
69 info(std::format(format, std::forward<Args>(args)...));
70}
71
76void warn(const std::string& message);
77
84template <typename... Args> void warn(std::format_string<Args...> format, Args&&... args)
85{
86 warn(std::format(format, std::forward<Args>(args)...));
87}
88
93void error(const std::string& message);
94
100template <typename... Args> void error(std::format_string<Args...> format, Args&&... args)
101{
102 error(std::format(format, std::forward<Args>(args)...));
103}
104
111void progress(float progress, std::string message);
112
119template <typename... Args>
120void progress(float prog, std::format_string<Args...> format, Args&&... args)
121{
122 progress(prog, std::format(format, std::forward<Args>(args)...));
123}
124
125} // namespace asw::log
126
127#endif // ASW_LOG_H
Definition log.h:16
void set_output(std::ostream &stream)
Set the output stream (default: std::cerr).
Definition log.cpp:158
void info(const std::string &message)
Log an info message.
Definition log.cpp:168
void debug(const std::string &message)
Log a debug message.
Definition log.cpp:163
void log_message(Level level, const std::string &message)
Log a message at the specified level. Messages below the current log level are ignored.
Definition log.cpp:112
void error(const std::string &message)
Log an error message.
Definition log.cpp:178
void warn(const std::string &message)
Log a warning message.
Definition log.cpp:173
Level
Log severity levels.
Definition log.h:19
void progress(float progress, std::string message)
Log a progress message with a percentage.
Definition log.cpp:183
void set_level(Level level)
Set the minimum log level (messages below this are ignored).
Definition log.cpp:153