Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
base_writer.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
5#pragma once
6
7#include <string>
8#include <chrono>
9
10// Use common_system's standard interface
11#include <kcenon/common/interfaces/logger_interface.h>
12#include <kcenon/common/patterns/result.h>
18
71namespace kcenon::logger {
72
96public:
110 explicit base_writer(std::unique_ptr<log_formatter_interface> formatter = nullptr);
111
112 virtual ~base_writer() = default;
113
132 common::VoidResult write(const log_entry& entry) override = 0;
133
153 common::VoidResult flush() override = 0;
154
166 virtual void set_use_color(bool use_color) {
167 use_color_ = use_color;
168 }
169
176 bool use_color() const {
177 return use_color_;
178 }
179
191 virtual std::string get_name() const override = 0;
192
207 virtual bool is_healthy() const override { return true; }
208
218 log_formatter_interface* get_formatter() const;
219
220protected:
233 std::string format_log_entry(const log_entry& entry) const;
234
235private:
237 std::unique_ptr<log_formatter_interface> formatter_;
238
240 bool use_color_ = true;
241};
242
243} // namespace kcenon::logger
Abstract base class for all log output writers.
Definition base_writer.h:95
common::VoidResult flush() override=0
Flush any buffered data.
common::VoidResult write(const log_entry &entry) override=0
Write a log entry using the modern interface.
virtual ~base_writer()=default
virtual void set_use_color(bool use_color)
Set whether to use color output (if supported)
bool use_color() const
Get current color output setting.
virtual bool is_healthy() const override
Check if the writer is healthy and operational.
std::unique_ptr< log_formatter_interface > formatter_
virtual std::string get_name() const override=0
Abstract interface for log message formatters.
Base interface for all log writers and decorators.
Error codes specific to the logger system.
Data structures for representing log entries and source locations kcenon.
Interface for log message formatters (Strategy Pattern) kcenon.
Base interface for all log writers and decorators.
DLL export/import macros for logger_system shared library support.
#define LOGGER_SYSTEM_API
Represents a single log entry with all associated metadata.
Definition log_entry.h:155