Skip to main content

ConsoleSink Class

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

Declaration

class helios::util::log::ConsoleSink { ... }

Base class

classhelios::util::log::LogSink

Public Member Functions Index

SinkTypeIdtypeId () const noexcept override

Returns the unique type identifier for this sink. More...

voidwrite (LogLevel level, const std::string &scope, const std::string &message) override

Writes a formatted log message to stdout. More...

voidflush () override

Flushes the stdout buffer. More...

Public Static Attributes Index

static constexpr SinkTypeIdTYPE_ID = "console"

Unique type identifier for this sink. More...

Description

LogSink implementation that writes to standard output.

This is the default sink for console-based logging. Output is formatted with level prefix and scope tag, mirroring the original Logger behavior.

Definition at line 23 of file ConsoleSink.ixx.

Public Member Functions

flush()

void helios::util::log::ConsoleSink::flush ()
inline virtual

Flushes the stdout buffer.

Definition at line 61 of file ConsoleSink.ixx.

61 void flush() override {
62 std::cout.flush();
63 }

typeId()

SinkTypeId helios::util::log::ConsoleSink::typeId ()
inline nodiscard noexcept virtual

Returns the unique type identifier for this sink.

Returns

"console".

Definition at line 36 of file ConsoleSink.ixx.

36 [[nodiscard]] SinkTypeId typeId() const noexcept override {
37 return TYPE_ID;
38 }

Reference TYPE_ID.

write()

void helios::util::log::ConsoleSink::write (LogLevel level, const std::string & scope, const std::string & message)
inline virtual

Writes a formatted log message to stdout.

Parameters
level

The severity level of the message.

scope

The source scope/module name.

message

The log message text.

Definition at line 47 of file ConsoleSink.ixx.

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 }

References helios::util::log::Debug, helios::util::log::Error, helios::util::log::Info and helios::util::log::Warn.

Public Static Attributes

TYPE_ID

SinkTypeId helios::util::log::ConsoleSink::TYPE_ID = "console"
constexpr static

Unique type identifier for this sink.

Definition at line 29 of file ConsoleSink.ixx.

29 static constexpr SinkTypeId TYPE_ID = "console";

Referenced by typeId.


The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.