Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
writer_category.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
29#include <type_traits>
30#include <cstdint>
31
32namespace kcenon::logger {
33
34// Forward declarations
35class log_writer_interface;
36class base_writer;
37
50enum class writer_category : std::uint8_t {
59};
60
81
102
123
144
145// ============================================================================
146// Type Traits
147// ============================================================================
148
155template<typename T>
156struct is_sync_writer : std::is_base_of<sync_writer_tag, T> {};
157
158template<typename T>
160
167template<typename T>
168struct is_async_writer : std::is_base_of<async_writer_tag, T> {};
169
170template<typename T>
172
179template<typename T>
180struct is_decorator_writer : std::is_base_of<decorator_writer_tag, T> {};
181
182template<typename T>
184
191template<typename T>
192struct is_composite_writer : std::is_base_of<composite_writer_tag, T> {};
193
194template<typename T>
196
197// ============================================================================
198// C++20 Concepts
199// ============================================================================
200
211template<typename T>
212concept SyncWriter = std::is_base_of_v<log_writer_interface, T> &&
213 std::is_base_of_v<sync_writer_tag, T>;
214
225template<typename T>
226concept AsyncWriter = std::is_base_of_v<log_writer_interface, T> &&
227 std::is_base_of_v<async_writer_tag, T>;
228
239template<typename T>
240concept DecoratorWriter = std::is_base_of_v<log_writer_interface, T> &&
241 std::is_base_of_v<decorator_writer_tag, T>;
242
253template<typename T>
254concept CompositeWriter = std::is_base_of_v<log_writer_interface, T> &&
255 std::is_base_of_v<composite_writer_tag, T>;
256
257// ============================================================================
258// Runtime Category Query
259// ============================================================================
260
271template<typename T>
273 if constexpr (is_composite_writer_v<T>) {
275 } else if constexpr (is_decorator_writer_v<T>) {
277 } else if constexpr (is_async_writer_v<T>) {
279 } else if constexpr (is_sync_writer_v<T>) {
281 } else {
282 // Default for untagged writers
284 }
285}
286
294constexpr const char* to_string(writer_category cat) noexcept {
295 switch (cat) {
296 case writer_category::synchronous: return "synchronous";
297 case writer_category::asynchronous: return "asynchronous";
298 case writer_category::decorator: return "decorator";
299 case writer_category::composite: return "composite";
300 }
301 return "unknown";
302}
303
304} // namespace kcenon::logger
Concept for asynchronous writers.
Concept for composite writers.
Concept for decorator writers.
Concept for synchronous writers.
constexpr bool is_sync_writer_v
constexpr bool is_async_writer_v
constexpr bool is_composite_writer_v
constexpr const char * to_string(writer_category cat) noexcept
Get string representation of writer category.
writer_category
Categories of log writers based on operational behavior.
constexpr bool is_decorator_writer_v
constexpr writer_category get_writer_category()
Get the primary category of a writer type.
Tag interface for asynchronous writers.
static constexpr writer_category category
Tag interface for composite writers.
static constexpr writer_category category
Tag interface for decorator writers.
static constexpr writer_category category
Type trait to check if a writer is asynchronous.
Type trait to check if a writer is composite.
Type trait to check if a writer is a decorator.
Type trait to check if a writer is synchronous.
Tag interface for synchronous writers.
static constexpr writer_category category