Skip to content

Comments

fix: log rotation issue and remove unused name parameter#871

Merged
myakove merged 2 commits intomainfrom
fix-logs
Oct 19, 2025
Merged

fix: log rotation issue and remove unused name parameter#871
myakove merged 2 commits intomainfrom
fix-logs

Conversation

@myakove
Copy link
Collaborator

@myakove myakove commented Oct 19, 2025

Fixed log rotation not working at 10MB threshold due to multiple
logger instances creating separate RotatingFileHandler objects for
the same log file.

Changes:

  • Modified get_logger_with_params() to use fixed logger name based on
    log file path, ensuring single RotatingFileHandler per file
  • Removed unused 'name' parameter from get_logger_with_params()
  • Updated all callers (7 files) to remove name argument
  • Updated tests to reflect new logger naming pattern

The issue was in our code, not in python-simple-logger. Multiple
handlers writing to same file caused rotation to fail because each
handler independently tracks file size.

Now all code writing to same log file shares one logger instance
with one handler, ensuring proper rotation at 10MB threshold.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced sensitive data masking in logs to better protect passwords, tokens, API keys, credentials, private keys, and webhook identifiers from being exposed in logging output.
  • Refactor

    • Optimized internal logging initialization for improved stability and handler rotation management.

Fixed log rotation not working at 10MB threshold due to multiple
logger instances creating separate RotatingFileHandler objects for
the same log file.

Changes:
- Modified get_logger_with_params() to use fixed logger name based on
  log file path, ensuring single RotatingFileHandler per file
- Removed unused 'name' parameter from get_logger_with_params()
- Updated all callers (7 files) to remove name argument
- Updated tests to reflect new logger naming pattern

The issue was in our code, not in python-simple-logger. Multiple
handlers writing to same file caused rotation to fail because each
handler independently tracks file size.

Now all code writing to same log file shares one logger instance
with one handler, ensuring proper rotation at 10MB threshold.
@myakove-bot
Copy link
Collaborator

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: A tracking issue is created for this PR and will be closed when the PR is merged or closed
  • Pre-commit Checks: pre-commit runs automatically if .pre-commit-config.yaml exists
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest build-container - Rebuild and test container image
  • /retest python-module-install - Test Python package installation
  • /retest pre-commit - Run pre-commit hooks and checks
  • /retest conventional-title - Validate commit message format
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. LGTM Count: Minimum 1 /lgtm from reviewers
  3. Status Checks: All required status checks must pass
  4. No Blockers: No WIP, hold, or conflict labels
  5. Verified: PR must be marked as verified (if verification is enabled)

📊 Review Process

Approvers and Reviewers

Approvers:

  • myakove
  • rnetser

Reviewers:

  • myakove
  • rnetser
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@coderabbitai
Copy link

coderabbitai bot commented Oct 19, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request refactors the get_logger_with_params() function to remove the name parameter and instead derive the logger name internally from the log file path using a fixed cache key. All call sites are updated to remove the explicit name argument. The function adds comprehensive sensitive pattern masking. No control flow changes.

Changes

Cohort / File(s) Summary
Core function refactor
webhook_server/utils/helpers.py
Removed name parameter from get_logger_with_params() signature; introduced logger_cache_key derived from log file path for consistent logger naming; added comprehensive mask_sensitive_patterns list for filtering sensitive data (passwords, tokens, API keys, etc.); updated all internal call sites (get_github_repo_api, run_command, get_api_with_highest_rate_limit, log_rate_limit) to use new signature.
Logger initialization updates
webhook_server/app.py, webhook_server/utils/app_utils.py, webhook_server/utils/github_repository_and_webhook_settings.py, webhook_server/utils/github_repository_settings.py, webhook_server/utils/webhook.py
Updated all logger initialization calls from get_logger_with_params(name="...") to get_logger_with_params(), removing explicit name parameter while maintaining repository-specific context where applicable.
Test updates
webhook_server/tests/test_helpers.py
Updated test cases to reflect removed name parameter; verified logger derivation from log file path and repository context handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

The review requires understanding the new cache-key-based logger naming strategy and verifying all call sites are correctly updated. While most changes are homogeneous (removing the name parameter), the core function signature change and new mask_sensitive_patterns logic add moderate complexity.

Possibly related PRs

Suggested labels

size/L

Suggested reviewers

  • rnetser

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix: log rotation issue and remove unused name parameter" directly and clearly reflects the main changes in the pull request. The title captures both the primary problem being solved (log rotation not triggering at 10MB) and the key technical approach to fix it (removing the unused name parameter from get_logger_with_params()). All aspects mentioned in the title are present in the changeset across multiple files, and the title uses the conventional commit format. The title is concise, specific, and avoids vague terminology or file lists, making it immediately clear what the core change is about.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea2d317 and 2dfe434.

📒 Files selected for processing (1)
  • webhook_server/utils/helpers.py (6 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Extended mask_sensitive_patterns list to cover more credential and
authentication scenarios found in the codebase.

New patterns added:
- Authentication: username, login, -u, --username, --creds
- Tokens: api_key, github_token, GITHUB_TOKEN, pypi
- Secrets: webhook_secret, webhook-secret
- Private keys: private_key, private-key
- GitHub App: github-app-id
- Slack: slack-webhook-url, webhook-url
- Command flags: --password (in addition to -p)

This ensures sensitive data is masked in logs when using:
- Docker/Podman login commands
- Registry authentication
- PyPI token publishing
- GitHub API operations
- Slack webhook notifications
- Environment variables in commands

All patterns are case-sensitive to avoid over-masking.
@myakove
Copy link
Collaborator Author

myakove commented Oct 19, 2025

/verified
/approve

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
webhook_server/utils/helpers.py (1)

75-82: Core fix logic is sound with one minor comment clarity issue.

The fixed logger name strategy correctly ensures a single RotatingFileHandler per log file. The edge case handling (log_file or 'console') is appropriate.

However, the comment at Line 78 stating "The original 'name' parameter is preserved in log records via the logger name" may confuse readers since the name parameter was removed. Consider clarifying that log records will now contain the cache key (e.g., webhook-server-<filepath>) rather than caller-provided names.

Consider this comment revision for clarity:

-    # The original 'name' parameter is preserved in log records via the logger name.
+    # Log records will use this cache key as the logger name for consistent identification.
LOG_ROTATION_FIX.md (1)

1-153: Excellent documentation explaining the fix.

The documentation clearly explains the problem, root cause, solution, and verification. This will be valuable for future maintainers.

The static analysis tool flagged some minor markdown formatting issues (missing blank lines around code blocks, ordered list numbering, missing language identifier on one code block at line 98). These are cosmetic but could be addressed for consistency with markdown standards.

If desired, you can address the markdown linting issues:

  • Add blank lines before/after fenced code blocks
  • Change line 53 list numbering from 3. to 1. (for 1/1/1 style)
  • Add language identifier to code block at line 98
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e7cda0 and ea2d317.

📒 Files selected for processing (8)
  • LOG_ROTATION_FIX.md (1 hunks)
  • webhook_server/app.py (2 hunks)
  • webhook_server/tests/test_helpers.py (2 hunks)
  • webhook_server/utils/app_utils.py (1 hunks)
  • webhook_server/utils/github_repository_and_webhook_settings.py (1 hunks)
  • webhook_server/utils/github_repository_settings.py (1 hunks)
  • webhook_server/utils/helpers.py (6 hunks)
  • webhook_server/utils/webhook.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
webhook_server/tests/test_helpers.py (1)
webhook_server/utils/helpers.py (1)
  • get_logger_with_params (25-88)
webhook_server/utils/github_repository_settings.py (1)
webhook_server/utils/helpers.py (1)
  • get_logger_with_params (25-88)
webhook_server/utils/webhook.py (1)
webhook_server/utils/helpers.py (1)
  • get_logger_with_params (25-88)
webhook_server/app.py (1)
webhook_server/utils/helpers.py (1)
  • get_logger_with_params (25-88)
webhook_server/utils/github_repository_and_webhook_settings.py (1)
webhook_server/utils/helpers.py (1)
  • get_logger_with_params (25-88)
webhook_server/utils/app_utils.py (1)
webhook_server/utils/helpers.py (1)
  • get_logger_with_params (25-88)
🪛 markdownlint-cli2 (0.18.1)
LOG_ROTATION_FIX.md

53-53: Ordered list item prefix
Expected: 1; Actual: 3; Style: 1/1/1

(MD029, ol-prefix)


54-54: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


67-67: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


98-98: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)


98-98: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


146-146: Fenced code blocks should be surrounded by blank lines

(MD031, blanks-around-fences)

🔇 Additional comments (11)
webhook_server/utils/helpers.py (3)

25-28: LGTM! Signature change correctly addresses the root cause.

Removing the name parameter is the right fix. By deriving the logger name internally from the log file path, all code writing to the same file will share a single logger instance and RotatingFileHandler, ensuring correct rotation at the 10MB threshold.


29-60: Helpful reorganization of sensitive patterns.

The categorization with comments improves readability and maintainability. While this refactor is technically independent of the log rotation fix, it's a valuable improvement.


106-106: LGTM! Internal call sites correctly updated.

All internal calls to get_logger_with_params() within this file have been properly updated to remove the name argument, consistent with the new signature.

Also applies to: 129-129, 190-190, 236-236

webhook_server/utils/github_repository_and_webhook_settings.py (1)

14-14: LGTM! Logger initialization correctly updated.

The call to get_logger_with_params() now uses the new signature without the name parameter, ensuring this module shares the same logger instance (and RotatingFileHandler) with other code writing to the same log file.

webhook_server/utils/webhook.py (1)

13-13: LGTM! Logger initialization correctly updated.

The removal of name="webhook" ensures this module shares the logger instance with other modules writing to the same log file, enabling proper log rotation.

webhook_server/utils/github_repository_settings.py (1)

45-45: LGTM! Logger initialization correctly updated.

Consistent with the log rotation fix, this change ensures a shared logger instance per log file.

webhook_server/utils/app_utils.py (1)

19-19: LGTM! Logger initialization correctly updated.

The change aligns with the new get_logger_with_params() signature, ensuring proper log rotation behavior.

webhook_server/tests/test_helpers.py (2)

64-76: LGTM! Tests correctly updated for new signature.

The test assertions properly validate the new logger naming pattern (webhook-server- prefix) and confirm the function works correctly with and without the repository_name parameter.


222-234: LGTM! Test correctly validates repository-specific logger behavior.

The test appropriately verifies that get_logger_with_params(repository_name="repo") creates loggers with the expected directory structure and naming.

webhook_server/app.py (2)

46-46: LGTM! Global logger initialization correctly updated.

The removal of name="main" ensures this module participates in the shared logger instance strategy for proper log rotation.


213-213: LGTM! Repository-specific logger correctly configured.

The per-repository logger appropriately uses the repository_name parameter to maintain repository context while benefiting from the shared logger instance behavior.

@myakove myakove merged commit bf0a7fd into main Oct 19, 2025
7 of 9 checks passed
@myakove myakove deleted the fix-logs branch October 19, 2025 10:52
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.

2 participants