In this section, we will extend the debugging example in Chapter 6, Learning to Program Console Input/Output, to include a rudimentary logger. The goal of this logger is to redirect additions to the std::clog stream to a log file in addition to the console.
Just like the debugging functions in Chapter 6, Learning to Program Console Input/Output, we would like the logging functions to be compiled out if the debugging level is not sufficient, or if debugging has been disabled.
To accomplish this, please see the following code: https://github.com/PacktPublishing/Hands-On-System-Programming-with-CPP/blob/master/Chapter08/example1.cpp.
To start, we will need to create two constant expressions—one for the debug level, and one to enable or disable debugging outright, as follows:
#ifdef DEBUG_LEVEL
constexpr auto g_debug_level = DEBUG_LEVEL;
#else...