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 <cstdint>
7#include <optional>
8#include <string>
9
10USERVER_NAMESPACE_BEGIN
11
12/// Logging macro and utilities
13namespace logging {
14
15/// Log levels
16enum class Level : std::uint8_t {
17 kTrace = 0,
18 kDebug = 1,
19 kInfo = 2,
20 kWarning = 3,
21 kError = 4,
22 kCritical = 5,
23 kNone = 6
24};
25
26inline constexpr auto kLevelMax = static_cast<int>(Level::kNone);
27
28/// @brief Converts lowercase level name to a corresponding Level, throws
29/// std::runtime_error if no matching log level found.
31
32/// @brief Returns a string representation of logging level, e.g. "info"
34
35/// @brief Returns a string representation of logging level, e.g. "INFO"
37
38/// @brief Returns std::nullopt if level_name is std::nullopt, otherwise
39/// behaves exactly like logging::LevelFromString.
40std::optional<Level> OptionalLevelFromString(const std::optional<std::string>& level_name);
41
42} // namespace logging
43
44USERVER_NAMESPACE_END