ORE Studio 0.0.4
Loading...
Searching...
No Matches
file_log_exporter.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_EXPORTING_FILE_LOG_EXPORTER_HPP
21#define ORES_TELEMETRY_EXPORTING_FILE_LOG_EXPORTER_HPP
22
23#include <mutex>
24#include <fstream>
25#include <filesystem>
26#include "ores.telemetry/exporting/log_exporter.hpp"
27
29
46class file_log_exporter final : public log_exporter {
47public:
54 explicit file_log_exporter(const std::filesystem::path& path);
55
56 ~file_log_exporter() override;
57
66 void export_record(domain::log_record record) override;
67
71 void flush() override;
72
76 void shutdown() override;
77
78private:
79 std::mutex mutex_;
80 std::ofstream file_;
81 bool is_open_;
82};
83
84}
85
86#endif
Log export functionality for telemetry.
Definition file_log_exporter.hpp:28
A log record with trace correlation.
Definition log_record.hpp:46
Exports log records to a JSON Lines file.
Definition file_log_exporter.hpp:46
void flush() override
Flushes the file stream.
Definition file_log_exporter.cpp:139
void export_record(domain::log_record record) override
Exports a log record as a JSON line.
Definition file_log_exporter.cpp:105
void shutdown() override
Closes the file.
Definition file_log_exporter.cpp:146
Interface for exporting telemetry log records.
Definition log_exporter.hpp:36