Thanks to visit codestin.com
Credit goes to github.com

Skip to content

logger: remove deprecated compat logger#3273

Merged
back-to merged 2 commits into
streamlink:masterfrom
bastimeyer:deprecations/logger-removal
Oct 21, 2020
Merged

logger: remove deprecated compat logger#3273
back-to merged 2 commits into
streamlink:masterfrom
bastimeyer:deprecations/logger-removal

Conversation

@bastimeyer

@bastimeyer bastimeyer commented Oct 19, 2020

Copy link
Copy Markdown
Member

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
Comment thread src/streamlink/logger.py Outdated
Comment thread src/streamlink/logger.py Outdated
@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
Copy Markdown
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
snorkelopsstgtesting1-spec pushed a commit to snorkel-marlin-repos/streamlink_streamlink_pr_3273_8f55ed37-c2ef-4ecc-a4e6-892b65e85c58 that referenced this pull request Oct 22, 2025
Original PR #3273 by bastimeyer
Original: streamlink/streamlink#3273
snorkelopstesting3-bot added a commit to snorkel-marlin-repos/streamlink_streamlink_pr_3273_8f55ed37-c2ef-4ecc-a4e6-892b65e85c58 that referenced this pull request Oct 22, 2025
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