Skip to content

LogLevel

Maxime ROUFFET edited this page Apr 1, 2024 · 6 revisions

Log levels are used to filter logs by severity level.
The available levels are available through the enum class SA::LogLevel with the values:

Normal

The default level, used for fast debugging.

Info

Initialization/Uninitialization, resource creation/destruction information logging.

Warning

Code generated a warning which might cause a potential issue: implementation should be checked.

Error

Error as occurred: serious debugging is required.

AssertSuccess

Assertion test resulted in success. Exception not thrown but still log the exception to access performed test as a string.

AssertFailure

Assertion test resulted in failure. Force log exception despite any parameters before throw.

Enabling/Disabling LogLevel

Global

The functions EnableLogLevel and DisableLogLevel are accessible from the Logger class to enable/disable a log level in all registered streams.
Example:

// Disable Warning LogLevel for all streams.
SA::Debug::logger->DisableLogLevel(SA::LogLevel::Warning);

// Enable AssertionSuccess LogLevel for all streams.
SA::Debug::logger->EnableLogLevel(SA::LogLevel::AssertionSuccess);

Per-Stream

A levelFlags is accessible in each LogStream to control whether or not a log with this level should be output.
Example:

// Create and register LogStream.
SA::ConsoleLogStream& cslStream  = SA::Debug::logger->CreateLogStream<SA::ConsoleLogStream>();

// Remove warning level.
cslStream.levelFlags &= ~SA::LogLevel::Warning;

// Add AssertionSuccess level.
cslStream.levelFlags |= SA::LogLevel::AssertionSuccess;