Skip to content

logger: remove deprecated compat logger #3273

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

Merged
merged 2 commits into from
Oct 21, 2020

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Oct 19, 2020

Split into two commits, each with a description of the changes in the commit message bodies.

Things to note:

  1. BREAKING: Due to the removal of the custom LogRecord class, log calls cannot use the curly bracket format style with custom LogRecord args anymore, like log.info("foo {0}", bar). The default Python behavior is the percent format style, but that's not recommended here, as log messages should all be pre-formatted via f-strings or string.format calls, to make them independent of the logging implementation.
  2. BREAKING: This will change the trace logging format from [18:30:35,123] to [18:30:35.123456]
  3. BREAKING: The LogRecord's msecs won't get used for formatting the trace log and instead its created attribute gets used via datetime.fromtimestamp(record.created) and datetime.strftime("%f"), as it already contains the microseconds value. This also fixes a formatting bug that could result into logging something like this [18:27:35,1000], which was supposed to be fixed by cli.main: fix msecs format in logging output #3025.
  4. I don't know why ConsoleOutput had the set_level method for changing the log level of the main logger class. ConsoleOutput is supposed to write to stdout/stderr directly and is thus unrelated to the logger.

@bastimeyer bastimeyer mentioned this pull request Oct 19, 2020
25 tasks
@bastimeyer bastimeyer force-pushed the deprecations/logger-removal branch from eedb834 to 801f59c Compare October 19, 2020 18:33
@bastimeyer bastimeyer added the WIP Work in process label Oct 19, 2020
@bastimeyer
Copy link
Member Author

I will open a PR later that corrects all log calls in every Streamlink module. After that PR has been merged, I'm going to remove the custom LogRecord class and makeRecord method here, as they can be removed then.

- remove old Logger and LoggerModule classes
- remove old {,Compat}LogRecord classes
- remove deprecated and unneeded methods from StreamlinkLogger
- remove usage of old Logger from Session
- remove session reference from ConsoleOutput
- Format time via datetime.strftime instead of time.strftime
  This avoids needing to format the logrecord's msecs separately
- Change datefmt of trace level logging to "%H:%M:%S.%f"
- Remove redundant StringFormatter.format code
- Fix StringFormatter.usesTime() being called twice during format
- Calculate usesTime value only once (depends on format, not record)
- Add tests
@bastimeyer bastimeyer force-pushed the deprecations/logger-removal branch from 801f59c to 70dc809 Compare October 20, 2020 15:56
@bastimeyer bastimeyer removed the WIP Work in process label Oct 20, 2020
@back-to back-to merged commit 79f3a49 into streamlink:master Oct 21, 2020
@bastimeyer bastimeyer deleted the deprecations/logger-removal branch January 19, 2021 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants