python-devtools icon indicating copy to clipboard operation
python-devtools copied to clipboard

[Feature Request] Can debug print output to a configured logger?

Open zhuoqun-chen opened this issue 2 years ago • 3 comments

debug is a wonderful tool and saved me a lot of time for debugging. And In my projects, I used to configure my owner logger for recording some running information. And now I use both debug() and logger.debug().

However, when they are used together, the terminal looks like this:

image

But another tool I'm using called Hydra can also format some information into its configured logger, and the result looks like this: image

So I assume if debug can offer similar option, it will be amazing.

Can your team kindly consider to support this feature?

Appreciated your maintenance. Thanks!

zhuoqun-chen avatar Mar 15 '23 09:03 zhuoqun-chen

What about debug.format?

alexmojaki avatar Aug 01 '23 17:08 alexmojaki

What about debug.format?

Hi alexmojaki,

Thanks for the advice! But currently I'm not sure how to use debug.format function to do this because the integration with a custom logger is not listed in the documentation of devtools.

Or are you suggesting something like:

a = torch.tensor([1, 2, 3])
logger.debug(debug.format(a))

Could you please give me more explanations or examples? Thx again.

zhuoqun-chen avatar Aug 19 '23 09:08 zhuoqun-chen

debug.format() takes the same arguments debug() but returns the formatted string instead of printing it.

samuelcolvin avatar Aug 19 '23 09:08 samuelcolvin