JustAnotherDnDGame 0.1.0
Jeu de rôle tactique au d20, vue de dessus, en C++/Qt
Loading...
Searching...
No Matches
LogLevelParse.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Valentin Eloy
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include <cctype>
7#include <optional>
8#include <string>
9#include <string_view>
10
12
17
18namespace core {
19
25[[nodiscard]] inline std::optional<LogLevel> parseLogLevel(std::string_view text) {
26 std::string lowered;
27 lowered.reserve(text.size());
28 for (const char character : text) {
29 lowered.push_back(static_cast<char>(std::tolower(static_cast<unsigned char>(character))));
30 }
31
32 if (lowered == "trace") {
33 return LogLevel::Trace;
34 }
35 if (lowered == "info") {
36 return LogLevel::Info;
37 }
38 if (lowered == "warning" || lowered == "warn") {
39 return LogLevel::Warning;
40 }
41 if (lowered == "error") {
42 return LogLevel::Error;
43 }
44 return std::nullopt;
45}
46
47} // namespace core
Niveaux de journalisation, par gravité croissante.
Espace de noms du moteur et de la logique de jeu.
Definition Bootstrap.h:9
@ Warning
Anomalie non bloquante.
Definition LogLevel.h:17
@ Info
Information de fonctionnement normal.
Definition LogLevel.h:16
@ Error
Erreur nécessitant attention.
Definition LogLevel.h:18
@ Trace
Détails fins de débogage.
Definition LogLevel.h:15
std::optional< LogLevel > parseLogLevel(std::string_view text)
Convertit une chaîne en niveau de log (insensible à la casse).
Definition LogLevelParse.h:25