DescentDevelopers / Descent3

Descent 3 by Outrage Entertainment
GNU General Public License v3.0
2.88k stars 251 forks source link

Logging framework #537

Closed winterheart closed 1 month ago

winterheart commented 3 months ago

Currently we have a somewhat crippled logging facility based on an old ddebug/mono submodule. It is available only on Debug and does not provide any useful information on Release build. There was another attempt to use the spdlog library (#212), but we reverted it as it added unneeded external dependency.

For our needs logging framework should have following features:

After some research I'd like to propose to switch the plog library (https://github.com/SergiusTheBest/plog) as the most suitable solution.

Lgt2x commented 3 months ago

ok for the lib, also noting that it uses CMake (easy integration) and allows sharing instances across libs, which is going to be handy for logging in network code and level scripts. I would prefer actual functions to macros for easier debugging, but it's fine.

A few notes/questions:

Jayman2000 commented 3 months ago

Why is plog a better option than spdlog?

winterheart commented 2 months ago

Why is plog a better option than spdlog?

Main issue of spdlog that we forced to pull extra dependencies from outside into build process like external libfmt.

Jayman2000 commented 2 months ago

Why is plog a better option than spdlog?

Main issue of spdlog that we forced to pull extra dependencies from outside into build process like external libfmt.

I agree that it’s a good thing that plog has less dependencies than spdlog (As far as I can tell, plog only depends on the standard library which is great!). That being said, I disagree that having extra dependencies is the main issue of spdlog.

Here’s what I think that the main issue of spdlog is: when we were using spdlog, we had three different logging systems, mprintf(), SDL_LogMessage() and spdlog. Even if we get rid of the mprintf() stuff entirely, we would still be left with two different logging systems. As long as we depend on SDL, we also depend on SDL_LogMessage(). If we want all log messages to go through spdlog, then we would have to write a custom SDL_LogOutputFunction because SDL uses its own logging functions internally (example).

I’m skeptical about using plog because I don’t think that it makes sense to have two different logging systems for one program. I think that it would make more sense to just define macros that call SDL_LogMessage() with any additional data that we want embedded in the log message (filename, line number, timestamp, etc.).

Lgt2x commented 1 month ago

Implemented by #546 and #587 . Very happy with how it turned out