Skip to main content

ConsoleSink.ixx File

Log sink that writes to stdout. More...

Included Headers

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

Namespaces Index

namespacehelios
namespaceengine
namespaceutil
namespacelog

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
5module;
6
7#include <iostream>
8#include <string>
9
10export module helios.engine.util.log.ConsoleSink;
11
12import helios.engine.util.log.LogSink;
13
14export namespace helios::engine::util::log {
15
23 class ConsoleSink : public LogSink {
24
25 public:
29 static constexpr SinkTypeId TYPE_ID = "console";
30
37 return TYPE_ID;
38 }
39
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
61 void flush() override {
62 std::cout.flush();
63 }
64 };
65
66}
67

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.