-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
cli: implement --logfile #3753
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
cli: implement --logfile #3753
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.
Btw, the tests are not as thorough and clean as I'd like them to be, because the entire CLI is a total mess.
The download progress stuff however is working correctly and the logfile doesn't affect it, which means it still gets written to stderr. Same as prompts for user input.
gravyboat
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.
Looks good to me.
|
Would it make sense adding a prompt when trying to write to an existing file, similar to |
|
Hmm, I don't really see the benefit of a prompt when writing to an existing file. I would imagine most people writing out log files are going to be comfortable with log rotate or understand the basics of what they are doing. |
|
@bastimeyer, |
|
The reason why I asked about a prompt and whether to append or not is that the log output is not that useful if it gets appended to an existing file, because there's no real "preamble" that would make it clear that a new Streamlink instance is writing to the log file. Maybe it'd make sense always logging the used arguments (
This doesn't solve the issue I just mentioned. It's meant for proper log rotation and requires a maxBytes and backupCount value. And then there are also other handlers which might be preferred by some user instead. I'm not sure this fits into the scope of Streamlink's CLI. My idea of the logfile argument is being able to write the log output of a single Streamlink instance into a separate file, not having a continuous/shared logfile of multiple instances, because it's not really useful. This also raises the question whether a default logfile path could be used when |
That wasn't meant to be either.
With default values of |
- always exit streamlink_cli.main.main at the same function call, namely log_current_arguments - patch out dummy functions in context manager - slice debug log mock calls due to common test exit function - properly reset mocks - rename streamlink_cli.main.check_root to log_root_warning - add test for streamlink_cli.main.log_root_warning
506df4b to
8a7357a
Compare
- refactor streamlink_cli.main.{setup_logging,setup_console}
and split into setup_logger_and_console and setup_signals
- add LOG_DIR to streamlink_cli.constants
- pass filename to logger.basicConfig
- re-use write stream of logger in ConsoleOutput
- fix escaped chars for percent-formatted argparse help strings in docs
- add tests
|
@bastimeyer Are we good here or are you still working? |
|
Yes, sorry about the confusion. After pushing the latest changes I updated the text of the OP, but didn't add a new comment. Unless someone has any concerns, this should be good. I was waiting for another review, as I've changed a ton since your review. The tests are now done properly and cover both POSIX and Windows paths. To sum up the changes again:
What could have been done differently:
|
|
@bastimeyer I looked over the changes after you forced pushed 2 days ago and everything looks even better than it originally did. I'm going to merge this in, thanks for the improvements. |
- always exit streamlink_cli.main.main at the same function call, namely log_current_arguments - patch out dummy functions in context manager - slice debug log mock calls due to common test exit function - properly reset mocks - rename streamlink_cli.main.check_root to log_root_warning - add test for streamlink_cli.main.log_root_warning
based on streamlink#3753 cannot implement because many issues with py2, py3, no py2 pathlib no tests applied yet
based on streamlink#3753 the implementation don't use pathlib and therefore not all tests applied
based on streamlink#3753 - os.path is used instead of pathlib - only basic logfile tests w/o write_file_and_assert()
based on streamlink#3753 - os.path is used instead of pathlib - only basic logfile tests w/o write_file_and_assert()
based on streamlink#3753 cannot implement because many issues with py2, py3, no py2 pathlib no tests applied yet
Original PR #3753 by bastimeyer Original: streamlink/streamlink#3753
Merged from original PR #3753 Original: streamlink/streamlink#3753
log_current_arguments
and split into setup_logger_and_console and setup_signals
Resolves #2485