numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
log_tag_config.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 <utility>
23
29
30namespace num_collect::logging {
31
38public:
42 log_tag_config() = default;
43
49 [[nodiscard]] auto sink() const noexcept -> const sinks::log_sink& {
50 return sink_;
51 }
52
60 sink_ = std::move(val);
61 return *this;
62 }
63
69 [[nodiscard]] auto output_log_level() const noexcept -> log_level {
70 return output_log_level_;
71 }
72
80 switch (val) {
85 case log_level::info:
89 case log_level::off:
90 break;
91 default:
92 throw invalid_argument("Invalid log level.");
93 }
95 return *this;
96 }
97
103 [[nodiscard]] auto output_log_level_in_child_iterations() const noexcept
104 -> log_level {
106 }
107
115 -> log_tag_config& {
116 switch (val) {
117 case log_level::trace:
118 case log_level::debug:
121 case log_level::info:
123 case log_level::error:
125 case log_level::off:
126 break;
127 default:
128 throw invalid_argument("Invalid log level.");
129 }
131 return *this;
132 }
133
139 [[nodiscard]] auto iteration_output_period() const noexcept -> index_type {
141 }
142
150 if (val <= 0) {
151 throw invalid_argument(
152 "iteration_output_period must be a positive integer.");
153 }
155 return *this;
156 }
157
163 [[nodiscard]] auto iteration_label_period() const noexcept -> index_type {
165 }
166
174 if (val <= 0) {
175 throw invalid_argument(
176 "iteration_label_period must be a positive integer.");
177 }
179 return *this;
180 }
181
182private:
185
188
191
194
197
200
203};
204
205} // namespace num_collect::logging
Class of exception on invalid arguments.
Definition exception.h:85
Class to hold configurations for log tags.
index_type iteration_label_period_
Period to write labels of iteration logs.
auto iteration_output_period() const noexcept -> index_type
Get the period to write iteration logs.
auto sink(sinks::log_sink val) -> log_tag_config &
Set the log sink.
auto iteration_label_period(index_type val) -> log_tag_config &
Set the period to write labels of iteration logs.
log_tag_config()=default
Constructor.
auto sink() const noexcept -> const sinks::log_sink &
Get the log sink.
auto output_log_level(log_level val) -> log_tag_config &
Set the minimum log level to output.
auto iteration_label_period() const noexcept -> index_type
Get the period to write labels of iteration logs.
auto output_log_level_in_child_iterations() const noexcept -> log_level
Get the minimum log level to output in child iterations.
static constexpr index_type default_iteration_label_period
Default period to write labels of iteration logs.
auto iteration_output_period(index_type val) -> log_tag_config &
Set the period to write iteration logs.
index_type iteration_output_period_
Period to write iteration logs.
auto output_log_level_in_child_iterations(log_level val) -> log_tag_config &
Set the minimum log level to output in child iterations.
log_level output_log_level_in_child_iterations_
Minimum log level to output in child iterations.
auto output_log_level() const noexcept -> log_level
Get the minimum log level to output.
static constexpr index_type default_iteration_output_period
Default period to write iteration logs.
log_level output_log_level_
Minimum log level to output.
Declaration of the function to get the default log sink.
Definition of exceptions.
Definition of index_type type.
Definition of log_level enumeration.
Definition of log_sink class.
std::ptrdiff_t index_type
Type of indices in this library.
Definition index_type.h:33
NUM_COLLECT_EXPORT auto get_default_log_sink() -> log_sink
Get the default log sink.
log_level
Enumeration of log levels.
Definition log_level.h:47
@ off
Turn off output. (Only for output log level).