galaxy
1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
LogLevel.hpp
Go to the documentation of this file.
1
7
8
#ifndef GALAXY_LOGGING_LOGLEVEL_HPP_
9
#define GALAXY_LOGGING_LOGLEVEL_HPP_
10
11
#include <format>
12
#include <string>
13
14
#include <magic_enum/magic_enum.hpp>
15
16
namespace
galaxy
17
{
21
enum class
LogLevel
:
int
22
{
26
INFO
= 0,
27
31
WARNING
= 1,
32
36
ERROR
= 2,
37
41
FATAL
= 3
42
};
43
44
template
<LogLevel level>
45
constexpr
const
char
*
const
get_loglevel_colour
()
46
{
47
if
constexpr
(level ==
LogLevel::INFO
)
48
{
49
return
"\x1b[1m\x1b[37m"
;
50
}
51
else
if
constexpr
(level ==
LogLevel::WARNING
)
52
{
53
return
"\x1b[1m\x1b[33m"
;
54
}
55
else
if
constexpr
(level ==
LogLevel::ERROR
)
56
{
57
return
"\x1b[1m\x1b[31m"
;
58
}
59
else
if
constexpr
(level ==
LogLevel::FATAL
)
60
{
61
return
"\x1b[41m\x1b[37m"
;
62
}
63
}
64
}
// namespace galaxy
65
66
template
<>
67
struct
std::formatter<
galaxy
::LogLevel> : std::formatter<std::string>
68
{
69
auto
format
(
const
galaxy::LogLevel
& level, format_context& ctx)
const
70
{
71
return
std::formatter<std::string>::format(std::string {magic_enum::enum_name<galaxy::LogLevel>(level)}, ctx);
72
}
73
};
74
75
#endif
galaxy
Timer.hpp galaxy.
Definition
Timer.cpp:18
galaxy::LogLevel
LogLevel
Used to determine filtering and colouring of log messages.
Definition
LogLevel.hpp:22
galaxy::LogLevel::WARNING
@ WARNING
Warning Log Level.
galaxy::LogLevel::FATAL
@ FATAL
Fatal Log Level.
galaxy::LogLevel::INFO
@ INFO
Info Log Level.
galaxy::LogLevel::ERROR
@ ERROR
Error Log Level.
galaxy::get_loglevel_colour
constexpr const char *const get_loglevel_colour()
Definition
LogLevel.hpp:45
std::formatter< galaxy::LogLevel >::format
auto format(const galaxy::LogLevel &level, format_context &ctx) const
Definition
LogLevel.hpp:69
galaxy
src
galaxy
logging
LogLevel.hpp
Generated on Wed Aug 20 2025 08:06:51 for galaxy by
1.12.0