get rid of broken CStaticLoggerBase #19363
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When introducing
spdlog
I wanted to implement it in some classes for showcasing (e.g.CWebServer
and settings related classes). Because some of these classes were instantiated hundreds or even thousands of times I wanted to use a static logger. To simplify the integration and reduce code duplication I wrote aCStaticLoggerBase
class which took a logger name and provided a statics_logger
member variable.Obviously this approach doesn't work because all classes deriving from
CStaticLoggerBase
share the same static members so the logger stored ins_logger
would only be instantiated once for the first instantiated class deriving fromCStaticLoggerBase
and all other classes deriving from it would use the same logger with a mismatching name.This should probably also be considered for backporting because it results in bad log messages which might be confusing when trying to read the logs to track down an issue.
The approach I chose now is to provide a static
GetLogger()
helper in every class which previously derived fromCStaticLoggerBase
.Types of change
Checklist: