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_LOGGING_LIFECYCLE_MANAGER_HPP
21#define ORES_LOGGING_LIFECYCLE_MANAGER_HPP
22
23#include <memory>
24#include <optional>
25#include <filesystem>
26#include <boost/shared_ptr.hpp>
27#include <boost/log/sinks.hpp>
28#include "ores.logging/boost_severity.hpp"
29#include "ores.logging/logging_options.hpp"
30
31namespace ores::logging {
32
44protected:
45 using file_sink_type = boost::log::sinks::synchronous_sink<
46 boost::log::sinks::text_file_backend>;
47 using console_sink_type = boost::log::sinks::synchronous_sink<
48 boost::log::sinks::text_ostream_backend>;
49
50public:
52 lifecycle_manager& operator=(const lifecycle_manager&) = delete;
53
54protected:
60 static boost::shared_ptr<file_sink_type>
61 make_file_sink(std::filesystem::path path, boost_severity severity,
62 std::string tag);
63
67 static boost::shared_ptr<console_sink_type> make_console_sink(
68 boost_severity severity, std::string tag);
69
70public:
71
79 explicit lifecycle_manager(std::optional<logging_options> ocfg);
80
86 virtual ~lifecycle_manager();
87
88protected:
89 boost::shared_ptr<file_sink_type> file_sink_;
90 boost::shared_ptr<console_sink_type> console_sink_;
91};
92
93}
94
95#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
boost_severity
Internal Boost.Log severity level enum.
Definition boost_severity.hpp:40
Manages the starting and stopping of logging for an application.
Definition lifecycle_manager.hpp:43
static boost::shared_ptr< console_sink_type > make_console_sink(boost_severity severity, std::string tag)
Creates a boost log console sink.
Definition lifecycle_manager.cpp:103
virtual ~lifecycle_manager()
Shutdown logging for the entire application.
Definition lifecycle_manager.cpp:181
static boost::shared_ptr< file_sink_type > make_file_sink(std::filesystem::path path, boost_severity severity, std::string tag)
Creates a boost log file sink.
Definition lifecycle_manager.cpp:61