-
Book Overview & Buying
-
Table Of Contents
Test-Driven Development with C++
By :
The previous section identified the need to sometimes add a tag to log messages even if the tag is not given to the log function. We can use this to add a default log-level tag or any other default value needed for any tag.
With this feature, we’re starting to get to the need for the logging library to support configuration. What I mean is that we want to be able to tell the logging library how to behave before we call log, and we want the logging library to remember this behavior.
Most applications support logging only after the configuration is set once at the beginning of the application. This configuration setup is usually done at the beginning of the main function. So, let’s focus on adding some simple configuration that will let us set some default tags and then use those default tags when logging. If we encounter both a default tag and a tag with the same key used during a call to the log function, then we will use the tag provided...