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_TELEMETRY_LOG_LIFECYCLE_MANAGER_HPP
21#define ORES_TELEMETRY_LOG_LIFECYCLE_MANAGER_HPP
22
23#include <memory>
24#include <optional>
25#include <boost/shared_ptr.hpp>
26#include <boost/log/sinks.hpp>
27#include "ores.logging/lifecycle_manager.hpp"
28#include "ores.logging/logging_options.hpp"
29#include "ores.telemetry/log/telemetry_sink_backend.hpp"
30#include "ores.telemetry/log/database_sink_backend.hpp"
31#include "ores.telemetry/domain/resource.hpp"
32
33namespace ores::telemetry::log {
34
36
49private:
50 using telemetry_sink_type = boost::log::sinks::asynchronous_sink<
52
53public:
54 lifecycle_manager() = delete;
56 lifecycle_manager& operator=(const lifecycle_manager&) = delete;
57
58public:
68 explicit lifecycle_manager(std::optional<logging_options> ocfg);
69
75 ~lifecycle_manager() override;
76
98 std::shared_ptr<domain::resource> resource,
100
125 std::shared_ptr<domain::resource> resource,
126 database_log_handler handler,
127 const std::string& source_type = "test",
128 const std::string& source_name = "unit-test");
129
130private:
131 boost::shared_ptr<telemetry_sink_type> telemetry_sink_;
132 using database_sink_type = boost::log::sinks::asynchronous_sink<
134 boost::shared_ptr<database_sink_type> database_sink_; // Added for database sink
135};
136
137}
138
139#endif
Implements logging for ORE Studio.
Definition database_sink_backend.hpp:32
std::function< void(const domain::telemetry_log_entry &)> database_log_handler
Handler function type for processing log entries destined for database storage.
Definition database_sink_backend.hpp:41
Manages the starting and stopping of logging for an application.
Definition lifecycle_manager.hpp:43
Options related to logging.
Definition logging_options.hpp:32
Boost.Log sink backend that prepares logs for database storage.
Definition database_sink_backend.hpp:71
Extends the base lifecycle_manager with telemetry sink support.
Definition lifecycle_manager.hpp:48
void add_telemetry_sink(std::shared_ptr< domain::resource > resource, telemetry_sink_backend::log_record_handler handler)
Adds a telemetry sink for log record correlation.
Definition lifecycle_manager.cpp:54
~lifecycle_manager() override
Shutdown logging for the entire application.
Definition lifecycle_manager.cpp:35
void add_database_sink(std::shared_ptr< domain::resource > resource, database_log_handler handler, const std::string &source_type="test", const std::string &source_name="unit-test")
Adds a database sink for direct database logging.
Definition lifecycle_manager.cpp:71
Boost.Log sink backend that creates telemetry log_records.
Definition telemetry_sink_backend.hpp:54
std::function< void(domain::log_record)> log_record_handler
Handler function type for processing log records.
Definition telemetry_sink_backend.hpp:63