numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
toml_console_log_sink_factory.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 <toml++/toml.h>
23
29
31
38class toml_console_log_sink_factory final : public log_sink_factory_base {
39public:
45 explicit toml_console_log_sink_factory(const ::toml::table& table) {
46 read_optional_value_to(use_color_, table, "use_color",
47 "use_color in num_collect.logging.sinks element with type "
48 "\"console\"",
49 "a boolean");
50 }
51
53 [[nodiscard]] auto create(log_sink_factory_table& sinks)
54 -> sinks::log_sink override {
55 (void)sinks;
56 if (use_color_) {
58 }
60 }
61
65 ~toml_console_log_sink_factory() noexcept override = default;
66
68 const toml_console_log_sink_factory&) = delete;
70 auto operator=(const toml_console_log_sink_factory&)
72 auto operator=(toml_console_log_sink_factory&&)
74
75private:
77 bool use_color_{true};
78};
79
80} // namespace num_collect::logging::config::toml
~toml_console_log_sink_factory() noexcept override=default
Destructor.
auto create(log_sink_factory_table &sinks) -> sinks::log_sink override
Create log sink.
Declaration of functions to create console log sinks.
Definition of log_sink class.
Definition of log_sink_factory_base class.
Definition of log_sink_factory_table class.
Namespace of logging configuration in TOML files.
void read_optional_value_to(T &output, const ::toml::table &table, std::string_view path, std::string_view config_name, std::string_view type_name)
Read a value to a variable.
Definition toml_helper.h:70
Namespace of log sinks.
NUM_COLLECT_EXPORT auto create_non_colored_console_sink() -> log_sink
Create a log sink to write to console without color.
NUM_COLLECT_EXPORT auto create_colored_console_sink() -> log_sink
Create a log sink to write to console with color.
Definition of helper functions for parsing TOML files.