numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
parse_output_log_level_str.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 <string>
23#include <string_view>
24
25#include <fmt/format.h>
26
29
31
39[[nodiscard]] inline auto parse_output_log_level_str(std::string_view str)
40 -> log_level {
41 if (str == "trace") {
42 return log_level::trace;
43 }
44 if (str == "debug") {
45 return log_level::debug;
46 }
47 if (str == "iteration") {
49 }
50 if (str == "summary") {
51 return log_level::summary;
52 }
53 if (str == "info") {
54 return log_level::info;
55 }
56 if (str == "warning") {
57 return log_level::warning;
58 }
59 if (str == "error") {
60 return log_level::error;
61 }
62 if (str == "critical") {
64 }
65 if (str == "off") {
66 return log_level::off;
67 }
68 throw invalid_argument(fmt::format("Invalid log level {}.", str));
69}
70
71} // namespace num_collect::logging::config
Class of exception on invalid arguments.
Definition exception.h:85
Definition of exceptions.
Definition of log_level enumeration.
Namespace of logging configuration.
auto parse_output_log_level_str(std::string_view str) -> log_level
Parse a log level from a string to use in output_log_level of log_tag_config class.
log_level
Enumeration of log levels.
Definition log_level.h:47
@ off
Turn off output. (Only for output log level).