Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
log_writer_interface.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
12#pragma once
13
14#include <string>
15#include <chrono>
16#include <memory>
17#include <kcenon/common/patterns/result.h>
19
20namespace kcenon::logger {
21
22// Forward declaration
23struct log_entry;
24
51public:
52 virtual ~log_writer_interface() = default;
53
66 virtual common::VoidResult write(const log_entry& entry) = 0;
67
80
98 return flush();
99 }
100
118 [[nodiscard]] virtual auto is_open() const -> bool {
119 return true;
120 }
121
131 virtual std::string get_name() const = 0;
132
143 virtual bool is_healthy() const = 0;
144};
145
151using log_writer_ptr = std::unique_ptr<log_writer_interface>;
152
153} // namespace kcenon::logger
Base interface for all log writers and decorators.
virtual std::string get_name() const =0
virtual bool is_healthy() const =0
Check if the writer is healthy.
virtual common::VoidResult flush()=0
Flush any buffered data.
virtual common::VoidResult write(const log_entry &entry)=0
Write a log entry.
virtual auto is_open() const -> bool
Check if writer is open and ready.
virtual common::VoidResult close()
Close the writer and release resources.
Error codes specific to the logger system.
std::unique_ptr< log_writer_interface > log_writer_ptr
Type alias for writer unique pointer.
Represents a single log entry with all associated metadata.
Definition log_entry.h:155