-
Notifications
You must be signed in to change notification settings - Fork 8
Improve logging #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve logging #29
Conversation
Simplify the cli main function by pulling out the logging setup. The cli function is more difficualt to test, the more we can full out the easier it is to test. Signed-off-by: James McCorrie <[email protected]>
|
It looks like later versions of ruff have introduced some extra linting rules that now fail. I've added a commit that resolves the failed lints, although not directly related to this PR. |
rswarbrick
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look like nice cleanups! It's lovely to see things getting more solid.
Simplify logging with a custom logger. There is no need to import VERBOSE as this is replaced with a `log.verbose(...)` helper. Now that we have resolved all instances of LOG015, lets enable the rule in CI. Signed-off-by: James McCorrie <[email protected]>
It doesn't look like these scripts are used in this version of DVSim. Instead the versions shipped with OpenTitan are used if they are used at all. For the moment remove the shebangs and remove the executable flag from the files. They would not be useable from a package install anyway. When it comes to reintegrating with OpenTitan, then a new solution will be required. For the moment this patch resolves new failing linting checks. Signed-off-by: James McCorrie <[email protected]>
hcallahan-lowrisc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a custom logger is fine, but I would love to see us move to module-level loggers in the future. It has always bothered me that we never moved towards something properly idiomatic here.
Anyway, that's a future task. This is a great improvement for now, and long overdue! Thanks @machshev
The purpose of this PR is twofold:
Python programs and especially libraries should not use the default logger but create a logger instance. If you use the default logger, then setting the log level for example would set the log level for any 3rd party libraries used (polluting the logs and making them difficult to read). Typically a logger instance would would be crated at module level with something like
logger = logging.getLogger(__name__). For the moment though, lets start with something simpler and make it more complicated later if desired.The
LOG015lint rule checks for default logger use instances. In the DVSim codebase that accounts for129instances (out of1128lint fails). With this PR the total lint fails is reduced to a mere968;)