-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add an option to log to stdout #1473
base: master
Are you sure you want to change the base?
Conversation
@rockstorm101, @Fat-Zer, Reminder to myself: Best regards, DD |
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.
Thanks a lot for this PR, I'm generally happy with it. Just a couple of comments. Sorry it took me so long to review.
@@ -81,35 +81,38 @@ def format_length(mm, fractional=2): | |||
return '%%.%df' % fractional % units + suffix | |||
|
|||
class ConsoleOutputHandler: | |||
"""Handle console output. All messages go through the logging submodule. We setup a logging handler to get logged messages and write them to both stdout (unless a log file path is specified, in which case we add another logging handler to write to this file) and the log panel. | |||
We also redirect stdout and stderr to ourself to catch print messages and al.""" | |||
"""Handle console output. All messages go through the logging submodule. We setup a logging handler to get logged |
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.
Thanks for wrapping this test. Could we please wrap at 78 characters though? Something like this:
class ConsoleOutputHandler:
- """Handle console output. All messages go through the logging submodule. We setup a logging handler to get logged
- messages and write them to both stdout (unless a log file path is specified, in which case we add another logging
- handler to write to this file) and the log panel. We also redirect stdout and stderr to ourselves to catch print
- messages and al."""
+ """Handle console output. All messages go through the logging
+ submodule. We setup a logging handler to get logged messages and write
+ them to both stdout (unless a log file path is specified, in which case we
+ add another logging handler to write to this file) and the log panel. We
+ also redirect stdout and stderr to ourselves to catch print messages and
+ all."""
"""Handle console output. All messages go through the logging submodule. We setup a logging handler to get logged | ||
messages and write them to both stdout (unless a log file path is specified, in which case we add another logging | ||
handler to write to this file) and the log panel. We also redirect stdout and stderr to ourselves to catch print | ||
messages and al.""" |
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.
"and al" -> "et al"
self.stdout = sys.stdout | ||
self.stderr = sys.stderr | ||
sys.stdout = self | ||
sys.stderr = self | ||
self.print_on_stdout = not log_path | ||
if log_path: |
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 was worried about removing this check, but in my tests I could not make it fail due to this removal. So I'm happy with it. But if you could double check I would appreciate it.
Closes: https://github.com/Fat-Zer/Printrun/pull/new/log-stdout