[lldb-dev] [RFC] Simplifying logging code
Tamas Berghammer via lldb-dev
lldb-dev at lists.llvm.org
Wed Aug 12 03:52:28 PDT 2015
At the moment logging in LLDB done in the following way:
Log* log = GetLogIfAllCategoriesSet(...);
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(...);
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
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.
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the lldb-dev