numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
toml_single_file_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 <string>
23
24#include <toml++/toml.h>
25
31
33
41public:
47 explicit toml_single_file_log_sink_factory(const ::toml::table& table) {
48 filepath_ = require_value<std::string>(table, "filepath",
49 "filepath in num_collect.logging.sinks element with type "
50 "\"single_file\"",
51 "a string");
52 }
53
55 [[nodiscard]] auto create(log_sink_factory_table& sinks)
56 -> sinks::log_sink override {
57 (void)sinks;
59 }
60
64 ~toml_single_file_log_sink_factory() noexcept override = default;
65
67 const toml_single_file_log_sink_factory&) = delete;
70 auto operator=(const toml_single_file_log_sink_factory&)
72 auto operator=(toml_single_file_log_sink_factory&&)
74
75private:
77 std::string filepath_{};
78};
79
80} // namespace num_collect::logging::config::toml
Class to create log sinks to write to files without rotation using TOML configurations.
auto create(log_sink_factory_table &sinks) -> sinks::log_sink override
Create log sink.
~toml_single_file_log_sink_factory() noexcept override=default
Destructor.
Declaration of functions to create file 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.
auto require_value(const ::toml::table &table, std::string_view path, std::string_view config_name, std::string_view type_name) -> T
Get a value or throw exceptions.
Definition toml_helper.h:44
NUM_COLLECT_EXPORT auto create_single_file_sink(std::string_view filepath) -> log_sink
Create a log sink to write to a single file.
STL namespace.
Definition of helper functions for parsing TOML files.