API Reference
Classes
| Name | Description |
|---|---|
LoggerOptions |
Enumerations
LogLevel
The level of the log, the lower the number the higher the severity.
| Value | Description |
|---|---|
TRACE |
Most verbose log level. |
DEBUG |
Diagnostic information used for troubleshooting and testing. |
INFO |
Standard informational messages confirming that things are working as expected.. |
WARN |
Indicates an unexpected or abnormal event that does not disrupt current application. |
ERROR |
Used when a specific transaction or functionality fails, but the rest of the application stays running. |
PANIC |
It indicates a unexpected failure. Will call abort() after logging. |
FATAL |
The highest and most severe level. It indicates a catastrophic failure that crashes the application. Will call exit(EXIT_FAILURE) afterwards. |
LogType
How log outputs should look, standard or JSON.
| Value | Description |
|---|---|
STANDARD_FMT |
Standard log format, just printing [$LEVEL]: $MESSAGE |
JSON_FMT |
Output logs as JSON, {"$LEVEL": "$MESSAGE"} |
Functions
InitLogger
Initializes the Logger.
Parameters
| Parameter | Type | Description |
|---|---|---|
options |
struct LoggerOptions |
The LoggerOptions. |
InitLoggerEasy
Initializes the Logger the easy way — more defaults.
Parameters
| Parameter | Type | Description |
|---|---|---|
level |
enum LogLevel |
The log level from the LogLevel enum. |
PrintLoggerConfig
Pretty prints the current logger config.
Log
The most important function of this library - Logs a message.
Parameters
| Parameter | Type | Description |
|---|---|---|
level |
enum LogLevel |
The log level. |
message |
const char * |
The message itself to log. |
Panic
Similiar to Log but has a custom level and runs abort() at the end.
Parameters
| Parameter | Type | Description |
|---|---|---|
message |
const char * |
The message itself to log. |
SetLogLevel
Sets the log level for the logger.
Parameters
| Parameter | Type | Description |
|---|---|---|
level |
enum LogLevel |
What level to set to. |
StringToLogLevel
Sets the log level for the logger.
Returns
The log level as an enum value.
Parameters
| Parameter | Type | Description |
|---|---|---|
input_str |
const char * |
The desired log level as a string. |
GetLogLevel
Gets the current log level.
Returns
The current log level as an enum value.
LogLevelToString
Converts and returns a log level enum value as a string.
Returns
The current log level as an string value.
Parameters
| Parameter | Type | Description |
|---|---|---|
level |
enum LogLevel |
The desired log level as an enum value. |
LoggerOptions
Public Attributes
| Return | Name | Description |
|---|---|---|
enum LogLevel |
log_level |
level The log level from the LogLevel enum. |
enum LogType |
log_type |
The log type from the LogType enum. |
bool |
timestamp |
Turn on or off timestamps in logs. |
bool |
flush |
If true, fflush(stderr) will be called. |
bool |
newline |
If true, a newline will be inserted. |
bool |
color |
If true, color output will be enabled. |
bool |
display_level |
If true, the log level will be logged. |
log_level
Type: enum LogLevel
level The log level from the LogLevel enum.
log_type
Type: enum LogType
The log type from the LogType enum.
timestamp
Turn on or off timestamps in logs.
flush
If true, fflush(stderr) will be called.
newline
If true, a newline will be inserted.
color
If true, color output will be enabled.
display_level
If true, the log level will be logged.