EntropyEngine::Core::Logging
EntropyEngine::Core::Logging
Section titled “EntropyEngine::Core::Logging”Classes
Section titled “Classes”| Name | |
|---|---|
| class | EntropyEngine::Core::Logging::Logger Main logger class that manages sinks and provides logging interface. |
| struct | EntropyEngine::Core::Logging::LogEntry A single log entry containing all metadata and message. |
| class | EntropyEngine::Core::Logging::ILogSink Interface for log sinks that handle log output. |
| class | EntropyEngine::Core::Logging::ConsoleSink Log sink that outputs to console. |
| Name | |
|---|---|
| using std::shared_ptr< ILogSink > | LogSinkPtr Convenience typedef for shared sink pointers. |
| enum class uint8_t | LogLevel { Warning = 3, Trace = 0, Off = 6, Info = 2, Fatal = 5, Error = 4, Debug = 1} Log severity levels for controlling output verbosity. |
Functions
Section titled “Functions”| Name | |
|---|---|
| LogLevel | stringToLogLevel(const std::string & str) Convert string to LogLevel. |
| std::string_view | logLevelToString(LogLevel level) Convert log level to string representation. |
| char | logLevelToChar(LogLevel level) Convert log level to single character. |
Types Documentation
Section titled “Types Documentation”using LogSinkPtr
Section titled “using LogSinkPtr”using EntropyEngine::Core::Logging::LogSinkPtr = std::shared_ptr<ILogSink>;Convenience typedef for shared sink pointers.
enum LogLevel
Section titled “enum LogLevel”| Enumerator | Value | Description |
|---|---|---|
| Warning | 3 | Warning conditions that might require attention. |
| Trace | 0 | Detailed trace information for deep debugging. |
| Off | 6 | Disable all logging output. |
| Info | 2 | Informational messages about normal operation. |
| Fatal | 5 | Fatal errors that will terminate the application. |
| Error | 4 | Error conditions that require immediate attention. |
| Debug | 1 | Debug information useful during development. |
Log severity levels for controlling output verbosity.
Ordered from least to most severe. Setting a minimum level includes all more severe levels. E.g., Warning includes Warning, Error, Fatal.
Functions Documentation
Section titled “Functions Documentation”function stringToLogLevel
Section titled “function stringToLogLevel”inline LogLevel stringToLogLevel( const std::string & str)Convert string to LogLevel.
Parameters:
- str The string to parse
Return: Corresponding LogLevel, or Info if parsing fails
Case-insensitive. Accepts “WARN” for “WARNING”. Returns Info as default for unrecognized strings.
// Reading from configurationauto level = stringToLogLevel(config["log_level"]);logger.setLevel(level);
// Accepted formats:stringToLogLevel("debug"); // LogLevel::DebugstringToLogLevel("DEBUG"); // LogLevel::DebugstringToLogLevel("WARN"); // LogLevel::WarningstringToLogLevel("invalid"); // LogLevel::Info (default)function logLevelToString
Section titled “function logLevelToString”inline std::string_view logLevelToString( LogLevel level)Convert log level to string representation.
Parameters:
- level The log level to convert
Return: Level name (“TRACE”, “DEBUG”, etc.)
Returns fixed-width strings (5 chars) for consistent alignment.
std::cout << "[" << logLevelToString(LogLevel::Error) << "] " << "Failed to open file" << std::endl;// Output: "[ERROR] Failed to open file"function logLevelToChar
Section titled “function logLevelToChar”inline char logLevelToChar( LogLevel level)Convert log level to single character.
Parameters:
- level The log level to convert
Return: Single character (‘T’, ‘D’, ‘I’, ‘W’, ‘E’, ‘F’, ‘O’)
Useful for compact formats and grep operations.
// Compact format for high-volume loggingstd::cout << "[" << logLevelToChar(level) << "] " << timestamp << " " << message << std::endl;// Output: "[E] 2024-01-15 10:30:45 Connection lost"Updated on 2026-01-26 at 17:14:35 -0500