Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
LogLevel.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** R-Type
4** File description:
5** LogLevel.hpp, LogLevel enumeration declaration
6*/
7
8/*
9** MIT License
10**
11** Copyright (c) 2025 Robin Toillon
12**
13** Permission is hereby granted, free of charge, to any person obtaining
14** a copy of this software and associated documentation files (the
15** "Software"), to deal in the Software without restriction, including
16** without limitation the rights to use, copy, modify, merge, publish,
17** distribute, sublicense, and/or sell copies of the Software, and to
18** permit persons to whom the Software is furnished to do so, subject to
19** the following conditions:
20**
21** The above copyright notice and this permission notice shall be
22** included in all copies or substantial portions of the Software.
23**
24** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
28** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31*/
32
41#ifndef RTYPE_LOGLEVEL_HPP_
42 #define RTYPE_LOGLEVEL_HPP_
43
44 #include <cstdint>
45 #include <format>
46 #include <string_view>
47 #include <utility>
48
49namespace rtp::log
50{
57 enum class Level : std::uint8_t {
58 Debug = 0,
59 Info,
60 Warning,
61 Error,
62 Fatal,
63 None
64 };
65
66 constexpr std::string_view toString(Level level) noexcept;
67}
68
69template <>
70struct std::formatter<rtp::log::Level> : std::formatter<std::string_view> {
71 constexpr auto parse(std::format_parse_context& ctx) {
72 return ctx.begin();
73 }
80 auto format(rtp::log::Level level, std::format_context &ctx) const
81 {
82 return std::format_to(ctx.out(), "{}", rtp::log::toString(level));
83 }
84};
85
86 #include "LogLevel.inl" /* toString and format implementations */
87
88#endif /* !RTYPE_LOGLEVEL_HPP_ */
Level
Severity levels for log messages.
Definition LogLevel.hpp:57
@ Warning
Warning messages for potentially harmful situations.
@ Info
General informational messages.
@ None
No logging (used to disable logging)
@ Fatal
Fatal error messages indicating critical failures.
@ Error
Error messages for error events.
@ Debug
Detailed information for debugging purposes.
constexpr std::string_view toString(Level level) noexcept
constexpr auto parse(std::format_parse_context &ctx)
Definition LogLevel.hpp:71
auto format(rtp::log::Level level, std::format_context &ctx) const
Format an log::Level enum value.
Definition LogLevel.hpp:80