-
Notifications
You must be signed in to change notification settings - Fork 76
Description
Background
One long-standing issue about the compiler I have been meaning to address is the mechanism for reporting error & warning messages.
Rather than using Python's built-in logging library, I had for some reason implemented a custom message handling mechanism that is tightly bound to the mechanics of the compiler.
This is problematic for several reasons:
- Poor control of message handling, filtering, and output
- Difficult to use with compiler-adjacent tools like PeakRDL - one has to pass around a reference to the message handler class
- Reinvents something that already exists - Python's logging facility
Changes
Migrate the systemrdl-compiler to emit messages using Python's logging facility.
Specifically, the following changes will be made:
- Provide a new logging Formatter class that is specifically tailored for handling log messages that contain contextual RDL source referencing information. (basically provide a formatter that generates the exact same pretty error messages as before). To keep things easy to use, this formatter, along with a StreamHandler will be auto-loaded if no other handlers are found in the design.
- Implement an equivalent mechanism for trapping and escalating errors during compilation & elaboration (escalate to RDLCompileError exception where appropriate)
- Remove
systemrdl.messages.MessagePrinterandsystemrdl.messages.MessageHandler - Remove the optional
message_printerargument to theRDLCompilerconstructor - Remove references and usage of the MessageHandler at various points of the API (
RDLCompiler.msg,RDLImporter.msg, and other commonly-used places)
Migration plan & compatibility
In nearly all cases, this will not affect anyone since I have not seen much reliance on overriding the default message printer, or other API usages. That said, since this represents a change to a small portion of the publicly-facing API, a proper deprecation cycle will be used in case these changes affect other users.
If you think this change may affect you, be sure to subscribe to this issue page for updates.