Skip to main content

LogSink.ixx File

Abstract interface for log output destinations. More...

Included Headers

#include <string>

Namespaces Index

namespacehelios
namespaceutil

Utility functions and helper classes. More...

namespacelog

Logging system with self-registering output sinks. More...

Classes Index

classhelios::util::log::LogSink

Description

Abstract interface for log output destinations.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file LogSink.ixx
3 * @brief Abstract interface for log output destinations.
4 */
5module;
6
7#include <string>
8
9export module helios.util.log.LogSink;
10
11export namespace helios::util::log {
12
13 /**
14 * @brief Severity level for log messages.
15 */
16 enum class LogLevel {
21 };
22
23 /**
24 * @brief Unique identifier type for log sinks.
25 *
26 * Each sink implementation defines its own static identifier string.
27 * The LogManager uses these identifiers to enable/disable specific sinks.
28 *
29 * ```cpp
30 * // In sink implementation:
31 * static constexpr const char* TYPE_ID = "console";
32 * [[nodiscard]] const char* typeId() const noexcept override { return TYPE_ID; }
33 *
34 * // Usage:
35 * LogManager::getInstance().enableSink("console");
36 * LogManager::getInstance().disableSink("imgui");
37 * ```
38 */
39 using SinkTypeId = const char*;
40
41 /**
42 * @interface LogSink
43 * @brief Abstract sink interface for log message output.
44 *
45 * LogSink defines the contract for log output destinations. Implementations
46 * can write to console, files, ImGui widgets, network sockets, or any other
47 * target. Multiple sinks can be attached to a Logger for simultaneous output
48 * to different destinations.
49 *
50 * Each sink must provide a unique type identifier via `typeId()`. This allows
51 * the LogManager to selectively enable or disable sinks at runtime without
52 * requiring a central registry of all possible sink types.
53 */
54 class LogSink {
55
56 public:
57 virtual ~LogSink() = default;
58
59 /**
60 * @brief Returns the unique type identifier for this sink.
61 *
62 * Each sink implementation should define a static constexpr identifier
63 * and return it here. Used by LogManager to match sinks for enable/disable.
64 *
65 * @return A string identifier unique to this sink type (e.g., "console", "file").
66 */
67 [[nodiscard]] virtual SinkTypeId typeId() const noexcept = 0;
68
69 /**
70 * @brief Writes a log message to this sink.
71 *
72 * @param level The severity level of the message.
73 * @param scope The source scope/module name.
74 * @param message The log message text.
75 */
76 virtual void write(LogLevel level, const std::string& scope, const std::string& message) = 0;
77
78 /**
79 * @brief Flushes any buffered output (optional).
80 *
81 * Default implementation does nothing. Override for sinks that buffer.
82 */
83 virtual void flush() {}
84 };
85
86}
87

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.