-
Notifications
You must be signed in to change notification settings - Fork 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
Logging messages should not use string formatting #17
Comments
rpdelaney
added a commit
that referenced
this issue
Jun 7, 2018
This reverts commit 1f6b3b4. This introduced a bug where console errors were printed: --- Logging error --- Traceback (most recent call last): File "/usr/lib/python3.6/logging/__init__.py", line 992, in emit msg = self.format(record) File "/usr/lib/python3.6/logging/__init__.py", line 838, in format return fmt.format(record) File "/usr/lib/python3.6/logging/__init__.py", line 575, in format record.message = record.getMessage() File "/usr/lib/python3.6/logging/__init__.py", line 338, in getMessage msg = msg % self.args TypeError: not all arguments converted during string formatting Call stack: File "annotator/__main__.py", line 759, in <module> main() File "annotator/__main__.py", line 743, in main analyzed_game = analyze_game(game, args.gametime, args.engine, args.threads) File "annotator/__main__.py", line 590, in analyze_game game, root_node, ply_count = classify_opening(game) File "annotator/__main__.py", line 443, in classify_opening logger.info("Classifying the opening for non-variant ", variant, "game ...") Message: 'Classifying the opening for non-variant ' Arguments: ('chess', 'game ...') --- Logging error --- Traceback (most recent call last): File "/usr/lib/python3.6/logging/__init__.py", line 992, in emit msg = self.format(record) File "/usr/lib/python3.6/logging/__init__.py", line 838, in format return fmt.format(record) File "/usr/lib/python3.6/logging/__init__.py", line 575, in format record.message = record.getMessage() File "/usr/lib/python3.6/logging/__init__.py", line 338, in getMessage msg = msg % self.args TypeError: not all arguments converted during string formatting Call stack: File "annotator/__main__.py", line 759, in <module> main() File "annotator/__main__.py", line 743, in main analyzed_game = analyze_game(game, args.gametime, args.engine, args.threads) File "annotator/__main__.py", line 599, in analyze_game logger.debug("Total budget is {} seconds", budget) Message: 'Total budget is {} seconds' Arguments: (60.0,)
1f6b3b4 introduced a logger warning and so I reverted it in 6a6ae60.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very minor issue but I need to note this down so I don't forget to correct it later. I've just learned that while string formatting is recommended in many (most?) contexts, it is not a good idea in logging messages. Some explanation is here. The relevant pylint messages are:
The text was updated successfully, but these errors were encountered: