I propose that we create a LogTarget class so that we can create a log object representing both a tag set and a tag level.
With this class we write code as:
LogTarget(Debug, gc, heap) log;
if (log.is_enabled()) {
log.print(...);
log.print(...);
... = log.stream();
}
instead of the current model:
Log(gc, heap) log;
if (log.is_debug()) {
log.debug(...)
log.debug(...)
... = log.debug_stream():
}
The LogTarget class/macro ensures that we only mention the log level once, so that we don't accidentally log to the wrong level. The previous version forces the coder to repeat 'debug' four times.
With this class we write code as:
LogTarget(Debug, gc, heap) log;
if (log.is_enabled()) {
log.print(...);
log.print(...);
... = log.stream();
}
instead of the current model:
Log(gc, heap) log;
if (log.is_debug()) {
log.debug(...)
log.debug(...)
... = log.debug_stream():
}
The LogTarget class/macro ensures that we only mention the log level once, so that we don't accidentally log to the wrong level. The previous version forces the coder to repeat 'debug' four times.