Skip to content
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

Failed to initialize logger from file if one of the loggers already exists (spdlog 1.3.1) #43

Open
artemyv opened this issue Aug 7, 2019 · 1 comment

Comments

@artemyv
Copy link

artemyv commented Aug 7, 2019

If logger with specific name was created prior to call spdlog_setup::from_file_with_tag_replacement and logger with the same name encountered in the toml file - the spdlog library will throw the exception throw spdlog_ex("logger with name '" + logger_name + "' already exists"); when trying to create logger as a result whole initialization fails.

Probably better approach would be before trying to create logger with const auto logger = make_shared<spdlog::logger>( name, logger_sinks.cbegin(), logger_sinks.cend());
to query spdlog and if logger exists just replace the sinks using logger::sinks() api

@guangie88
Copy link
Owner

Hi apologies for the late response and thanks for the feedback.

Since it is subjective and better for some people to throw exception when this happens, it is more likely for me to consider putting some sort of flag to override and follow what you have suggested, to prevent accidental mistake in overriding, while allow users to override if needed to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants