Low priority.
In integrating WCT to Phlex, I discovered that its causing Phlex logging to go mute.
This is definitely bad behavior on WCT's part which I'll fix:
WireCell/wire-cell-toolkit#483
For Phlex, I suggest two things which would be good to consider in any case:
-
Phlex owns the program's main() so should assert whatever spdlog policy it wants even in the face of bratty plugins like WCT. In particular, it may be best to set (possibly reset) the default logger after all plugins are loaded.
-
Phlex should use a named, non-default logger (eg "phlex") and help plugins use their own named loggers.
WCT does this second one (thus is immune to its own stolen and sink-less default logger misbehavior).
From that experience, I can say that using multiple named spdlog loggers has a few positive and negative consequences:
Pros:
- logger name in the log line helps give some context.
- can set levels and sinks on a per named logger basis (rarely used but sometimes really useful)
- helps avoid but does not remove all cases of intertwined messages in MT setting.
Cons:
- one needs a mechanism to share logger names across whatever context makes sense. WCT does this with literal strings in each node class passed to a parent
Logger class.
- a logging component needs to carry a pointer to its logger instead of simply making a call to a bare
spdlog::info().
- a logger with a sink that buffers (stdout, file) will flush asynchronously with other such loggers. Lines in the flush are time-ordered but the block as a whole is sunk out of time order with others.
Low priority.
In integrating WCT to Phlex, I discovered that its causing Phlex logging to go mute.
This is definitely bad behavior on WCT's part which I'll fix:
WireCell/wire-cell-toolkit#483
For Phlex, I suggest two things which would be good to consider in any case:
Phlex owns the program's
main()so should assert whatever spdlog policy it wants even in the face of bratty plugins like WCT. In particular, it may be best to set (possibly reset) the default logger after all plugins are loaded.Phlex should use a named, non-default logger (eg "phlex") and help plugins use their own named loggers.
WCT does this second one (thus is immune to its own stolen and sink-less default logger misbehavior).
From that experience, I can say that using multiple named spdlog loggers has a few positive and negative consequences:
Pros:
Cons:
Loggerclass.spdlog::info().