Up to now I've been using spdlog for logging. I had decided that I would have a logger per system, plus a general logger for core library code, plus a general logger for game library code, plus a logger for json loading. Each logger from spdlog supports multiple sinks (outputs). One can quickly imagine that things get convoluted/complicated.
I like the idea of log "channels" (ie categories). That was the reason for the existence of loggers per system, etc. I realized that my approach was bloated.
I decided to ditch spdlog for a simple approach, that only uses fmtlib:
- We have log levels as usual: trace, debug, info, warn, error, fatal, off
- There are 2 outputs: file and gui. Both are configurable
- File output is parameterized on filename and most verbose log level
- Gui output is parameterized on history size (max line num) and default log level
- File output stores all logs, gui output shows only the selected channels (one or many), which helps wading through the logs
- Start with a fixed channel list (frequently used), but allow extensions. E.g. core library channels:
- app: application init/update related logs
- gfx: graphics subsystem
- gui: gui subsystem
- load: json loading subsystem
- core: everything else
- Allow runtime channel creation & use
Here's an example view of the gui console log, using imgui as usual: