Implement a Logging System with Configurable Log Levels
Description:
We need to create a logging system that allows for different levels of log visibility: show all logs, only show errors, and show warnings only. The logging level should be configurable using flags that can be passed as parameters when building the project with CMake.
Tasks:
Design the logging system:
Implement a logging system that supports different log levels:
Info: General information messages.
Warning: Potential issues that are not necessarily errors.
Error: Serious issues that could cause malfunctions.
Each log message should be timestamped and include the log level for easy identification.
Add CMake options for setting log level:
Add CMake options to control the logging level at build time:
LOG_LEVEL_ALL: Show all logs (Info, Warning, Error).
LOG_LEVEL_WARNING: Show only warnings and errors.
LOG_LEVEL_ERROR: Show only errors.
Set up default logging level if no flag is provided (e.g., LOG_LEVEL_ALL).
Modify the logging system to filter logs based on the specified level:
Implement filtering logic so that only logs matching the specified level are shown.
Ensure the logging system respects the selected log level and does not output messages below the configured threshold.
Configure CMake to accept log level flags as build parameters:
Modify the CMake configuration to allow setting the log level using flags like -DLOG_LEVEL_ALL, -DLOG_LEVEL_WARNING, or -DLOG_LEVEL_ERROR.
Pass the chosen log level as a preprocessor definition to the compiler.
Testing:
Test each log level configuration to ensure only the appropriate messages are displayed:
Test with LOG_LEVEL_ALL to verify that all messages (Info, Warning, Error) are shown.
Test with LOG_LEVEL_WARNING to confirm only warnings and errors appear.
Test with LOG_LEVEL_ERROR to ensure only error messages are displayed.
Test the CMake build process to ensure the flags work as intended and the logging level is correctly set at compile time.
Update documentation:
Document the logging system and the available log levels.
Update the CMake build instructions to include examples of how to set the log level using CMake flags.
Acceptance Criteria:
The logging system supports three log levels: Info, Warning, and Error.
CMake can be used to set the log level during the build process via flags.
The system correctly filters log messages based on the configured log level.
Documentation is updated with usage instructions for the logging system and build configuration.
Additional Context:
The logging system should be lightweight and not introduce significant performance overhead.
The default log level should be configurable in the CMake file to allow flexibility in different build configurations (e.g., Debug vs. Release).
Implement a Logging System with Configurable Log Levels
Description: We need to create a logging system that allows for different levels of log visibility:
show all logs
,only show errors
, andshow warnings only
. The logging level should be configurable using flags that can be passed as parameters when building the project with CMake.Tasks:
Design the logging system:
Add CMake options for setting log level:
LOG_LEVEL_ALL
: Show all logs (Info, Warning, Error).LOG_LEVEL_WARNING
: Show only warnings and errors.LOG_LEVEL_ERROR
: Show only errors.LOG_LEVEL_ALL
).Modify the logging system to filter logs based on the specified level:
Configure CMake to accept log level flags as build parameters:
-DLOG_LEVEL_ALL
,-DLOG_LEVEL_WARNING
, or-DLOG_LEVEL_ERROR
.Testing:
LOG_LEVEL_ALL
to verify that all messages (Info, Warning, Error) are shown.LOG_LEVEL_WARNING
to confirm only warnings and errors appear.LOG_LEVEL_ERROR
to ensure only error messages are displayed.Update documentation:
Acceptance Criteria:
Info
,Warning
, andError
.Additional Context: