-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added relay_sink. #3017
Added relay_sink. #3017
Conversation
@gabime Hi there, any comment on closing this? |
I am trying not to insert new features in this branch. All new developments is in v2.x branch. Also in v2.x it might be not needed since the static state is much smaller(no registry) and dlls can just receive logger pointer to use. |
Ah, ok on the frozen features. FWIW The main reason for this was that typically my DLLs initialize their own logger at the startup ( |
|
I can copy sinks, and basically already use this, instead of just copying the sinks from the target logger to the DLL logger, I put the target logger in the relay sink and put this sink into the DLL logger. The idea behind is that the target logger controls now globally the log level and also can easily control which sinks it uses. You can imagine an app which uses several DLLs, with this architecture, i.e. once the DLLs are loaded and initialized, the client app replaces all sinks in all DLLs with the This has proven to be quite flexible and powerful architecture. Right now I need to subclass |
Following our conversation, I would like to say that what would be really helpful, if |
Sure. PR is welcome. Should be very simple as it is just a wrapper around the void log_raw(const &details::log_msg msg) noexcept {
if (should_log(msg.log_level)) {
sink_it_(msg);
}
} |
Great, should I submit it against |
v2.x please |
Adds
relay_sink
, which just wraps a full featuredspdlog::logger
.This can be useful in an application which uses several standalone components (typically DLLs) where each instantiates its own
logger
to define an application specific log messages "routing".For example, during an initialization of each DLL, the app can chose to replace the DLLs loggers' sinks with the
relay_sink
with its own globallogger
and thus rerouting all log messages from all loggers through its own sinks, without destroying the DLLs' loggers.