python-devtools
python-devtools copied to clipboard
[Feature Request] Can debug print output to a configured logger?
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:

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

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!
What about debug.format?
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.
debug.format() takes the same arguments debug() but returns the formatted string instead of printing it.