ORE Studio 0.0.4
Loading...
Searching...
No Matches
lifecycle_manager.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_UTILITY_LOG_LIFE_CYCLE_MANAGER_HPP
21#define ORES_UTILITY_LOG_LIFE_CYCLE_MANAGER_HPP
22
23#include <optional>
24#include <filesystem>
25#include <boost/shared_ptr.hpp>
26#include <boost/log/sinks.hpp>
27#include "ores.utility/log/severity_level.hpp"
28#include "ores.utility/log/logging_options.hpp"
29
31
38class lifecycle_manager final {
39private:
40 using file_sink_type = boost::log::sinks::synchronous_sink<
41 boost::log::sinks::text_file_backend>;
42 using console_sink_type = boost::log::sinks::synchronous_sink<
43 boost::log::sinks::text_ostream_backend>;
44
45public:
46 lifecycle_manager() = delete;
48 lifecycle_manager& operator=(const lifecycle_manager&) = delete;
49
50private:
56 static boost::shared_ptr<file_sink_type>
57 make_file_sink(std::filesystem::path path, severity_level severity,
58 std::string tag);
59
63 static boost::shared_ptr<console_sink_type> make_console_sink(
64 severity_level severity, std::string tag);
65
66public:
67
75 explicit lifecycle_manager(std::optional<logging_options> ocfg);
76
83
84private:
85 boost::shared_ptr<file_sink_type> file_sink_;
86 boost::shared_ptr<console_sink_type> console_sink_;
87};
88
89}
90
91#endif
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
severity_level
Logging severity.
Definition severity_level.hpp:35
Manages the starting and stopping of logging for an application.
Definition lifecycle_manager.hpp:38
~lifecycle_manager()
Shutdown logging for the entire application.
Definition lifecycle_manager.cpp:159