Skip to main content

ConsoleSink.ixx File

Log sink that writes to stdout. More...

Included Headers

#include <iostream> #include <string> #include <helios.util.log.LogSink>

Namespaces Index

namespacehelios
namespaceutil

Utility functions and helper classes. More...

namespacelog

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

Classes Index

classConsoleSink

LogSink implementation that writes to standard output. More...

Description

Log sink that writes to stdout.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file ConsoleSink.ixx
3 * @brief Log sink that writes to stdout.
4 */
5module;
6
7#include <iostream>
8#include <string>
9
10export module helios.util.log.ConsoleSink;
11
12import helios.util.log.LogSink;
13
14export namespace helios::util::log {
15
16 /**
17 * @class ConsoleSink
18 * @brief LogSink implementation that writes to standard output.
19 *
20 * This is the default sink for console-based logging. Output is formatted
21 * with level prefix and scope tag, mirroring the original Logger behavior.
22 */
23 class ConsoleSink : public LogSink {
24
25 public:
26 /**
27 * @brief Unique type identifier for this sink.
28 */
29 static constexpr SinkTypeId TYPE_ID = "console";
30
31 /**
32 * @brief Returns the unique type identifier for this sink.
33 *
34 * @return "console".
35 */
36 [[nodiscard]] SinkTypeId typeId() const noexcept override {
37 return TYPE_ID;
38 }
39
40 /**
41 * @brief Writes a formatted log message to stdout.
42 *
43 * @param level The severity level of the message.
44 * @param scope The source scope/module name.
45 * @param message The log message text.
46 */
47 void write(LogLevel level, const std::string& scope, const std::string& message) override {
48 const char* levelStr = "";
49 switch (level) {
50 case LogLevel::Debug: levelStr = "[DEBUG]"; break;
51 case LogLevel::Info: levelStr = "[INFO]"; break;
52 case LogLevel::Warn: levelStr = "[WARN]"; break;
53 case LogLevel::Error: levelStr = "[ERROR]"; break;
54 }
55 std::cout << levelStr << "[" << scope << "] " << message << std::endl;
56 }
57
58 /**
59 * @brief Flushes the stdout buffer.
60 */
61 void flush() override {
62 std::cout.flush();
63 }
64 };
65
66}
67

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.