
Rob Stewart wrote:
From: John Torjo <john.lists@torjo.com>
What I want is to create a simple correspondence from a log_id (a level) into a log function. Having that, you can always say something like: LOG(activity) << whatever... << std::endl;
if 'activity' is turned off this nothing gets evaluated (yes, LOG is a macro ;))
But each invocation of operator <<() must be evaluated, if only to learn that the ostream is disabled, right? That could amount to a lot of overhead or clients would need to write custom functions that return a string from a set of arguments to reduce the number of operator <<() invocations.
Otherwise, it sounds useful.
Not if the LOG macro is something like: #define LOG(x) if(!is_log_enabled(x)) ; else x Then, LOG(x) << "me " << me << " and you " << you << std::endl; Writing will be evaluated only if is_log_enabled returns true. Best, John