A new guide in the Adafruit Learning System: A Logger for CircuitPython
In many environments you can go into a debugger and poke around. We don’t have that ability in CircuitPython, though. If you’re like this author, you sprinkle tactical
Afterwards you probably go through and remove them or comment them out. Sometimes you miss some. Sometimes you’d like to leave them in place and be able to turn them on and off. There are times when you’d like to see some debugging information, and other times when you want to be notified of critical errors only.
A logging framework will let you do all that and more.
Specifically, the logging framework described in this guide will:
- let you output messages at one of several levels of priority,
- ignore messages below a specific priority,
- automatically add a timestamp to messages,
- provide the string format method support for building messages,
- give you convenience methods for the outputting at standard priority levels,
- control where messages go, and
- make it easy to add new places for messages to go.
This guide will go over the use of the framework, walk through the implementation, and work through an example of adding a new destination capability.