userver: userver/logging/level.hpp Source File
Loading...
Searching...
No Matches
level.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/logging/level.hpp
4/// @brief Log levels
5
6#include <optional>
7#include <string>
8
9USERVER_NAMESPACE_BEGIN
10
11/// Logging macro and utilities
12namespace logging {
13
14/// Log levels
15enum class Level {
16 kTrace = 0,
17 kDebug = 1,
18 kInfo = 2,
19 kWarning = 3,
20 kError = 4,
21 kCritical = 5,
22 kNone = 6
23};
24
25inline constexpr auto kLevelMax = static_cast<int>(Level::kNone);
26
27/// @brief Converts lowercase level name to a corresponding Level, throws
28/// std::runtime_error if no matching log level found.
30
31/// @brief Returns a string representation of logging level, e.g. "info"
33
34/// @brief Returns a string representation of logging level, e.g. "INFO"
36
37/// @brief Returns std::nullopt if level_name is std::nullopt, otherwise
38/// behaves exactly like logging::LevelFromString.
40 const std::optional<std::string>& level_name);
41
42} // namespace logging
43
44USERVER_NAMESPACE_END