Suppose i have a statement like this
logging.debug('%r', do_really_expensive_computation())
or
logging.debug('%r', find_my_object().do_really_expensive_computation())
When logging level is set above DEBUG
it will not log, but it will still evaluate the arguments before calling logging.debug()
and execute do_really_expensive_computation()
also find_my_object()
could be quite heavy.
Is there any good pattern to skip all computation involved in logging when below current level?