Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
decorator_writer_base.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
13
14#include <stdexcept>
15
16namespace kcenon::logger {
17
18decorator_writer_base::decorator_writer_base(std::unique_ptr<log_writer_interface> wrapped,
19 std::string_view decorator_name)
20 : wrapped_(std::move(wrapped)), decorator_name_(decorator_name) {
21 if (!wrapped_) {
22 throw std::invalid_argument("decorator_writer_base: wrapped writer cannot be nullptr");
23 }
24}
25
29
31 return decorator_name_ + "_" + wrapped_->get_name();
32}
33
35 return wrapped_->is_healthy();
36}
37
39 return wrapped_.get();
40}
41
45
47 return *wrapped_;
48}
49
50const std::string& decorator_writer_base::decorator_name() const noexcept {
51 return decorator_name_;
52}
53
54} // namespace kcenon::logger
const std::string & decorator_name() const noexcept
Get the decorator name.
const log_writer_interface * get_wrapped_writer() const noexcept
Get the wrapped writer (const version)
common::VoidResult flush() override
Flush the wrapped writer.
std::string get_name() const override
Get the name of this writer.
std::unique_ptr< log_writer_interface > wrapped_
decorator_writer_base(std::unique_ptr< log_writer_interface > wrapped, std::string_view decorator_name)
Construct a decorator writer base.
bool is_healthy() const override
Check if the writer is healthy.
log_writer_interface & wrapped() noexcept
Access the wrapped writer (non-const)
Base interface for all log writers and decorators.
Base class for decorator pattern writers.