As we learned in the preceding recipe, logging has costs associated with it. It introduces delays to format log messages and writes them to persistent storage or a remote system.
Using log levels helps to reduce the overhead by skipping the writing of some messages to the log file. However, the message is usually being formatted before passing to a log function. For example, in the case of a system error, a developer wants to add an error code reported by the system to the log message. Although string formatting is generally less expensive than writing data to a file, it might still be an issue for highly-loaded systems or systems with limited resources.
Debug symbols added by a compiler do not add runtime overhead. However, they increase the size of the resulting binary. Moreover, performance optimizations made by the compiler can make interactive...