Skip to content

Conversation

@CuriousLearner
Copy link
Member

@CuriousLearner CuriousLearner commented Aug 2, 2018

@CuriousLearner
Copy link
Member Author

CuriousLearner commented Aug 7, 2018

@vsajip Hello, I see that there are various linting errors in test_logging.py which were fixed in 5f63c20. Does it make sense to separate them out in another Pull Request?

@willingc willingc self-requested a review October 7, 2018 09:23
@CuriousLearner
Copy link
Member Author

Hey @bitdancer , @vsajip

Can you please have a look at this? I just noticed this PR wasn't reviewed from almost a year. Please let me know, what is needed here.

Thanks!

@willingc
Copy link
Contributor

willingc commented May 9, 2019

@CuriousLearner I would go ahead and rebase to resolve conflicts.

@CuriousLearner
Copy link
Member Author

@willingc Done!

raise LineTooLong("status line")
if self.debuglevel > 0:
print("reply:", repr(line))
_log.info("reply: {}".format(repr(line)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging first argument support old format string, so _log.info("reply: %s", repr(line)) would work. There is mixed calls of {}".format(foo with %s", foo, wouldn't be better to stick with one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't be better to stick with one?

I agree - % should work fine and a lot of logging uses %-formatting rather than .format() due to its age.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another reason: tools like Sentry use message pattern as a key for logs grouping.
Adding pre-formatted messages to Sentry is very ineffective.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry!

I think I came back to this later and followed the same style as for other Python projects I was involved with.

Fixing this!

import io
import itertools
import os
import sys
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't being used anywhere!?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good catch. I think it remained here while I was working on this.

logger = logging.getLogger("http")
root_logger = self.root_logger
root_logger.removeHandler(self.root_logger.handlers[0])
logger = logging.getLogger("httplogger")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this name change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no specific reason for it. I'll just revert back.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Dec 15, 2024
@picnixz picnixz changed the title bpo-24255: Replace debug level-related logic in http client with logging gh-68443: Replace debug level-related logic in http client with logging Dec 15, 2024
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Feb 27, 2025
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Apr 13, 2025
@python-cla-bot
Copy link

python-cla-bot bot commented Apr 18, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Apr 18, 2025
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Jun 15, 2025
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Oct 12, 2025
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Nov 11, 2025
@CuriousLearner CuriousLearner removed the stale Stale PR or inactive for long period of time. label Nov 14, 2025
Replace debuglevel-based print statements with Python's standard
logging module for better integration with logging frameworks and
log aggregation tools like Sentry. Uses % formatting consistently
for better log pattern matching in aggregation tools.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants