Hi All,

At the moment logging in LLDB done in the following way:
Log* log = GetLogIfAllCategoriesSet(...);
if (log)
    log->Printf(...);

This approach is clean and easy to understand but have the disadvantage of
being a bit verbose. What is the general opinion about changing it to
something like this?
Logger log = GetLogIfAllCategoriesSet(...);
log.Printf(...);

The idea would be to return a new type of object from
GetLogIfAllCategoriesSet with small size (size of a pointer) what will
check if the log category is enabled. From efficiency perspective this
change would have no effect and it will simplify the writing of the logging
statements.

Implementation details:
Logger would just contain a pointer to a Log object and forward all call to
that object if that one isn't null. Additionally it will have a method to
check for nullness of the underlying log object if we want to do some
calculation only if the logging is enabled.

Thanks,
Tamas

P.S.: Other possible simplification in the logging system would be to
use LogIfAllCategoriesSet but it require the specification of the log
channel at each call and have a very minor overhead because of checking for
the enabled log categories at each call.
_______________________________________________
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

Reply via email to