Logger System
0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
thread_safe_writer.cpp
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
#include <
kcenon/logger/writers/thread_safe_writer.h
>
6
#include <
kcenon/logger/interfaces/log_entry.h
>
7
8
namespace
kcenon::logger
{
9
10
thread_safe_writer::thread_safe_writer
(std::unique_ptr<log_formatter_interface> formatter)
11
:
base_writer
(std::move(formatter)) {
12
}
13
14
common::VoidResult
thread_safe_writer::write
(
const
log_entry
& entry) {
15
std::lock_guard<std::mutex> lock(
write_mutex_
);
16
return
write_entry_impl
(entry);
17
}
18
19
common::VoidResult
thread_safe_writer::flush
() {
20
std::lock_guard<std::mutex> lock(
write_mutex_
);
21
return
flush_impl
();
22
}
23
24
}
// namespace kcenon::logger
kcenon::common::VoidResult
Definition
error_codes.h:116
kcenon::logger::base_writer
Abstract base class for all log output writers.
Definition
base_writer.h:95
kcenon::logger::thread_safe_writer::write_entry_impl
virtual common::VoidResult write_entry_impl(const log_entry &entry)=0
Implementation of structured write operation (override in derived classes)
kcenon::logger::thread_safe_writer::write
common::VoidResult write(const log_entry &entry) final
Thread-safe write operation for structured log entries.
Definition
thread_safe_writer.cpp:14
kcenon::logger::thread_safe_writer::write_mutex_
std::mutex write_mutex_
Definition
thread_safe_writer.h:178
kcenon::logger::thread_safe_writer::flush
common::VoidResult flush() final
Thread-safe flush operation.
Definition
thread_safe_writer.cpp:19
kcenon::logger::thread_safe_writer::thread_safe_writer
thread_safe_writer(std::unique_ptr< log_formatter_interface > formatter=nullptr)
Constructor with optional formatter.
Definition
thread_safe_writer.cpp:10
kcenon::logger::thread_safe_writer::flush_impl
virtual common::VoidResult flush_impl()=0
Implementation of flush operation (override in derived classes)
log_entry.h
Data structures for representing log entries and source locations kcenon.
kcenon::logger
Definition
common_logger_adapter.h:29
kcenon::logger::log_entry
Represents a single log entry with all associated metadata.
Definition
log_entry.h:155
thread_safe_writer.h
Thread-safe base class for writer implementations kcenon.
src
impl
writers
thread_safe_writer.cpp
Generated by
1.12.0