numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
log_level.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <cstdint>
23#include <string_view>
24
25#include <fmt/base.h>
26#include <fmt/format.h> // IWYU pragma: keep
27
28namespace num_collect::logging {
29
30// clang-format off
47enum class log_level : std::uint8_t { // clang-format on
49 trace,
50
52 debug,
53
56
59
61 summary,
62
64 info,
65
67 warning,
68
70 error,
71
74
76 off
77};
78
85[[nodiscard]] inline auto get_log_level_str(log_level level) noexcept
86 -> std::string_view {
87 switch (level) {
89 return "trace";
91 return "debug";
93 return "iteration";
95 return "iteration_label";
97 return "summary";
98 case log_level::info:
99 return "info";
101 return "warning";
102 case log_level::error:
103 return "error";
105 return "critical";
106 case log_level::off:
107 return "off";
108 }
109 return "unknown";
110}
111
112} // namespace num_collect::logging
113
114namespace fmt {
115
119template <>
120struct formatter<num_collect::logging::log_level>
121 : public formatter<string_view> {
122public:
130 auto format(
131 num_collect::logging::log_level val, format_context& context) const {
132 return formatter<string_view>::format(
134 }
135};
136
137} // namespace fmt
Namespace of fmt library.
Definition log_level.h:114
log_level
Enumeration of log levels.
Definition log_level.h:47
@ off
Turn off output. (Only for output log level).
@ iteration_label
Label of iterations.
auto get_log_level_str(log_level level) noexcept -> std::string_view
Get the log level string.
Definition log_level.h:85
Namespace of num_collect source codes.
auto format(num_collect::logging::log_level val, format_context &context) const
Format a value.
Definition log_level.h:130