On 19Nov2022 11:08, Stefan Ram <r...@zedat.fu-berlin.de> wrote:
<baran200...@gmail.com> writes:
You are expected to implement logging feature to an existing
code which uses the function below. [...]
You are not allowed to make changes in my_ugly_debug, so find another way.

 If found a solution that is even more ugly than your
 function. I was just about to post it here, but then
 remembered about the "no homework" rule. Bummer!

I suspect that the OP is just being asked to modify existing code which calls my_ugly_debug to use more conventional logging calls.

Baran, in addition to the various info(), warning() etc logging calls there is a log() logging call which accepts a log level (the warning() etc calls basicly call this with their own logging level).

I would be inclined to write a my_better_debug(s,level=0) function which took those existing levels (0,1,2) and mapped them to the official logging levels logging.INFO, logging.WARNING etc, and then called logging.log() with the official level.

Then adjust the calling code to call your new function.

The alternative is to just replace every calling function which uses my_ugly_debug() to directly call a logging.whatever() call.

Cheers,
Cameron Simpson <c...@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to