dkriegner / micro-flakes

https://dkriegner.github.io/micro-flakes/
GNU General Public License v3.0
0 stars 0 forks source link

Use python package logging for adjustable debug/info output #12

Closed dkriegner closed 1 year ago

dkriegner commented 1 year ago

We could use https://docs.python.org/3/library/logging.html to allow for an easily adjustable degree of logging output. The user could via a command line argument set the level of verbosity they expect in the output.

ji-ze commented 1 year ago

How to rewrite this: https://github.com/dkriegner/micro-flakes/blob/5bfe2fec0c2221210179c23176917f3028dc7a71/Detector/find_objects.py#L243

ji-ze commented 1 year ago

Info messages don't show in the terminal. After using logging.getLogger().setLevel(logging.INFO), all messages are red:

image
dkriegner commented 1 year ago

How to rewrite this:

https://github.com/dkriegner/micro-flakes/blob/5bfe2fec0c2221210179c23176917f3028dc7a71/Detector/find_objects.py#L243

I am not sure myself. Its possible that this can not be rewritten since a log entry is always a separate line

dkriegner commented 1 year ago

Info messages don't show in the terminal. After using logging.getLogger().setLevel(logging.INFO), all messages are red: image

I am pretty sure this is a particularity of your command line. usually info output is not red. Warnings/errors might be red. In my command line actually no logging output is red. There are lots of things which can be configured via the "handler" of the logger

ji-ze commented 1 year ago

I've just tried to open in the Windows terminal:

image

It doesn't look terrible.

dkriegner commented 1 year ago

I do not like much the INFO:root: part. you can remove this as outlined for example here: https://stackoverflow.com/questions/8353594/can-python-log-output-without-inforoot

It can be also useful to output there some timestamp instead. This is usually more helpful than the default output.

ji-ze commented 1 year ago

It works!

image