Genta-Technology / Kolosal

Apache License 2.0
1 stars 1 forks source link

Implement a Logging System with Configurable Log Levels #19

Open rifkybujana opened 1 month ago

rifkybujana commented 1 month ago

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:

  1. 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.
  2. 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).
  3. 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.
  4. 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.
  5. 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.
  6. 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:

Additional Context:

rifkybujana commented 1 month ago

Adding UI to these would be cool.

small popup window on the bottom right, containing messages for

rifkybujana commented 1 month ago

https://github.com/patrickcjk/imgui-notify