Skip to content
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

refactor: only replace password by star when logging level is debug #1820

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

waketzheng
Copy link
Contributor

Description

When db_url is 'postgres://postgres:[email protected]:5432/db_name'
logger msg will be: 'po***://po***:po***@127.0.0.1:5432/db_name'
that looks strange!

Motivation and Context

How Has This Been Tested?

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@coveralls
Copy link

coveralls commented Dec 20, 2024

Pull Request Test Coverage Report for Build 12441451819

Details

  • 3 of 14 (21.43%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 89.94%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tortoise/init.py 3 14 21.43%
Totals Coverage Status
Change from base Build 12437576482: -0.2%
Covered Lines: 6374
Relevant Lines: 6967

💛 - Coveralls

password,
# Show one third of the password at beginning (may be better for debugging purposes)
f"{password[0:len(password) // 3]}***",
if logger.isEnabledFor(logging.DEBUG):
Copy link
Contributor

Choose a reason for hiding this comment

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

The new code is overly complex. We shouldn't have something that complicated in the main file of the whole project. I would personally have more stars in the debug logs than 5 nested blocks of code to handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants