ko4life-net / ko

Open source development of the game Knight Online. This is a reversed engineered old version of the game aiming to replicate the nostalgic experience we all once had <3
https://github.com/ko4life-net/ko
MIT License
55 stars 22 forks source link

Refactor Logging Configuration for Flexibility and Performance #248

Closed stevewgr closed 3 months ago

stevewgr commented 3 months ago

Description

This pull request refactors the logging configuration to enhance flexibility and performance across different projects. The changes address the following needs and improvements:

  1. Flexibility Across Projects:

    • This class is utilized by multiple projects, each with unique requirements.
    • Some projects do not need spdlog as a dependency, but instead, only require the N3Base engine (e.g., our tools).
    • To accommodate these varied needs, the implementation is made more configurable through the use of preprocessor directives.
  2. Enhanced Configurability:

    • By introducing macros, we can control the inclusion of logging code based on project-specific needs.
    • When logs are disabled in release mode, no logging code will be generated. This optimization helps in improving the performance and reducing the final binary size.
  3. Trade-offs:

    • While this approach may make the code appear less elegant, the benefits in terms of flexibility and performance outweigh the aesthetic drawbacks.
    • The ability to manage the logging configuration in this way is crucial for its diverse use-cases.

In summary, these changes ensure that the logging system is more adaptable and efficient, catering to the specific needs of different projects without unnecessary dependencies.

stevewgr commented 3 months ago

Build passing: https://github.com/ko4life-net/ko/actions/runs/10276259671/job/28436376334

Merging.