-
Notifications
You must be signed in to change notification settings - Fork 347
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added logging mechanism to pyGHDL #2120
base: master
Are you sure you want to change the base?
Conversation
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.
The printouts are only in pyGHDL.dom
, so please move the logger instance to that package.
pyGHDL
itself has no outputs and will never have them.
As all messages are swallowed by the logger, a printout in https://github.com/ghdl/ghdl/blob/master/pyGHDL/cli/dom.py
is missing.
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.
The given implementation change doesn't have the same behavior.
- Messages do not print in order
Your PR master branch - Messages from CLI are not shown at all.
Your PR master branch
The purpose of pyGHDL.cli.dom
is to test and demonstrate capabilities of pyGHDL.dom
. So a printout of the translated structure is essential.
Also printing error messages at the point where they appear is also essential.
pyGHDL/cli/dom.py
Outdated
@@ -316,7 +317,7 @@ def HandlePretty(self, args): | |||
for line in PP.formatDesign(self._design, 1): | |||
buffer.append(line) | |||
|
|||
print("\n".join(buffer)) | |||
logger.info("\n".join(buffer)) |
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.
This output is not printed by logger.
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.
As this is a test application, I propose reverting these back to print statements.
@@ -118,7 +118,7 @@ def parse(cls, attributeNode: Iir) -> "AttributeSpecification": | |||
if nameKind == nodes.Iir_Kind.Simple_Name: | |||
names.append(SimpleName(name, GetNameOfNode(name))) | |||
elif nameKind == nodes.Iir_Kind.Signature: | |||
print("[NOT IMPLEMENTED] Signature name in attribute specifications.") | |||
logger.warning("[NOT IMPLEMENTED] Signature name in attribute specifications.") |
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.
Messages don't print in-order because of logger.
6740706
to
1d6eab6
Compare
Is ordering still a problem after the last update to this PR? |
Yes it is. I see 2 solutions to the problem:
Currently, print out are use to denote what's not translated to pyVHDLModel. Throwing an exception is no option, because it's not meant to be an exception and it would interrupt the translation, so almost no input could be translated. Should I investigate if we can add a flag like "development mode" or so? |
I think it makes sense to have a "debug" mode, which can be enabled by either a CLI option or an environment variable. Maybe |
I'll need some time for this change. |
No rush 馃槈 |
Description Please explain the changes you made here.
This PR introduces a basic logger to replace various print statements. The intention is to allow other tools using pyGHDL to be able customise the log level/format/stream.
馃毃 Before submitting your PR, please read contribute in the Docs, and review the following checklist:
No issues are being closed by this PR.
When contributing to the GHDL codebase...
When contributing to the docs...
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did, what alternatives you considered, etc.
鉂わ笍 Thank you!