bk1285 / rpi_wordclock

Software to create a Raspberry Pi based wordclock
GNU General Public License v3.0
214 stars 106 forks source link

Logging #178

Closed FabianReister closed 3 years ago

FabianReister commented 3 years ago

It is quite hard to identify errors on the command line as everything is printed without coloring.

There are great libraries available, such as the logging library that allows to specify several logging levels. In conjunction with coloredlogs, the command line output would be

image

The only changes need to be made are

__main__:

  import logging
  logging.basicConfig(level=logging.DEBUG)

  import coloredlogs
  coloredlogs.install()
  print = logging.info

to wordclock.py' main function. This sets print to be an info message (available levels: DEBUG, INFO, WARNING, ERROR).

coloredlogs can be installed from pypi (pip install coloredlogs) and could be wrapped with a try-catch-block to prevent import errors.

bk1285 commented 3 years ago

Nice, @FabianReister I'll consider that.

bk1285 commented 3 years ago

Thanks for the suggestion, @FabianReister :)