Rich logging support with polymorphic type conversion. More...
#include <richLog.hpp>
Public Member Functions | |
| noWrap (T rhs) | |
| T | unwrap () const |
Public Attributes | |
| T | data |
Rich logging support with polymorphic type conversion.
Uses polymorphism to convert format specifier arguments into appropriate types for logging. Since the clog module is positioned at a lower level in the architecture, it cannot know what classes depend on it. Therefore, richLog is defined in each module to specify how to convert classes in that module to strings.
richLog consists of two main parts: convert and wrap.
Defines how to convert each module's classes into types that are easy to log. Callers simply pass their concrete type to convert(), and the most appropriate convert is called via overloading. This means you can define both generic convert() and type-specific convert() simultaneously. A notable example is convert(void*), which is called when no other T* matches.
Wrap is needed to unpack values received from convert() so they can pass through variadic arguments. Variadic argument functions can only pass scalar types or T*, not values. Since some convert() functions create new values that need to be passed by value, wrap is essential as long as logger::log() uses variadic arguments.
convert() functions return either strWrap or noWrap<T>. noWrap returns the received value as-is without processing, while strWrap internally calls std::string::c_str().