Have you ever been working on code and needed a view into what was going on as it runs (or tries to)? 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 print
statements as needed.
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.
Parts
As this service uses RAM and space for longer programs, this guide will note use on M4 and nRF52840-based boards.
Text editor powered by tinymce.