Skip to content

Comments

feat: separate logs into mcp_server.log and logs_server.log#924

Merged
myakove merged 2 commits intomainfrom
feature/separate-logs
Nov 20, 2025
Merged

feat: separate logs into mcp_server.log and logs_server.log#924
myakove merged 2 commits intomainfrom
feature/separate-logs

Conversation

@myakove
Copy link
Collaborator

@myakove myakove commented Nov 20, 2025

  • Configure MCP logs to write to (configurable via ).
  • Configure Log Viewer logs to write to (configurable via ).
  • Keep main application logs in .
  • Update configuration schema and documentation.
  • Add helper for consistent log path resolution.
  • Add tests for logging separation.

Summary by CodeRabbit

  • New Features

    • Users can configure separate log files for MCP and the logs server via new options (mcp-log-file, logs-server-log-file) with sensible defaults.
  • Documentation

    • Configuration docs and schema updated to describe the new logging options and example usage.
  • Tests

    • New tests added to verify logging separation and log viewer initialization behave as expected.

✏️ Tip: You can customize this high-level summary in your review settings.

- Configure MCP logs to write to  (configurable via ).
- Configure Log Viewer logs to write to  (configurable via ).
- Keep main application logs in .
- Update configuration schema and documentation.
- Add helper  for consistent log path resolution.
- Add tests for logging separation.
@coderabbitai
Copy link

coderabbitai bot commented Nov 20, 2025

Walkthrough

Adds two new logging configuration options (mcp-log-file, logs-server-log-file), resolves log file paths, and wires dedicated loggers/handlers for MCP and the Logs Server; includes schema/docs updates and tests validating path resolution and logger initialization.

Changes

Cohort / File(s) Change Summary
Documentation & Configuration Schema
README.md, examples/config.yaml, webhook_server/config/schema.yaml
Added mcp-log-file and logs-server-log-file config options (with defaults and descriptions) to docs, example config, and schema.
Logging Utilities
webhook_server/utils/helpers.py
Added log_file_name param to get_logger_with_params, introduced get_log_file_path(config, log_file_name) to resolve/create log paths and updated logger cache key to use resolved path.
Logger Integration
webhook_server/app.py
When MCP enabled, create a dedicated MCP logger using mcp-log-file, attach handlers and disable propagation; initialize LogViewerController with a dedicated logger using logs-server-log-file.
Tests
webhook_server/tests/test_logging_separation.py
New tests covering absolute/relative/None log path resolution, MCP logger configuration (handler attachment and propagation), and LogViewerController logger initialization; heavy mocking to avoid side effects.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Pay attention to handler attachment and propagation control in webhook_server/app.py to avoid duplicate logging.
  • Review get_log_file_path behavior for relative vs absolute paths and directory creation (exist_ok=True).
  • Verify logger cache key change in helpers.py doesn't break caching semantics.
  • Check tests for correct singleton reset/mocking to ensure isolation.

Possibly related issues

  • myk-org/github-webhook-server#925 — Implements the same logging-separation feature (adds mcp-log-file and logs-server-log-file and wires them into logger setup), so it can be linked.

Possibly related PRs

  • #922 — Modifies MCP/logger setup and adds logging filters; touches the same initialization paths as this change.
  • #916 — Changes MCP initialization/lifespan logic in webhook_server/app.py, potentially interacting with the new MCP logger wiring.
  • #771 — Adjusts relative log-file path resolution in webhook_server/utils/helpers.py, overlapping with the introduced get_log_file_path refactor.

Suggested labels

size/XXL

Suggested reviewers

  • rnetser

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% 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 title 'feat: separate logs into mcp_server.log and logs_server.log' clearly and concisely summarizes the main change: implementing separate logging destinations for MCP and log viewer components.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/separate-logs

📜 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 f6d6df4 and 0316fb0.

📒 Files selected for processing (1)
  • webhook_server/config/schema.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • webhook_server/config/schema.yaml

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.

@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
    "
    f"* 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
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)

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.

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 (1)
webhook_server/config/schema.yaml (1)

13-18: Consider adding explicit default values for consistency.

The descriptions mention default values (default: mcp_server.log and default: logs_server.log), but the schema doesn't include a default field like other properties do (e.g., mask-sensitive-data on line 22). While the defaults are handled in code, adding them to the schema would improve consistency and enable validation tools to understand the complete configuration contract.

Apply this diff to add explicit defaults:

   mcp-log-file:
     type: string
     description: File path for the MCP log file (default: mcp_server.log)
+    default: mcp_server.log
   logs-server-log-file:
     type: string
     description: File path for the Logs Server log file (default: logs_server.log)
+    default: logs_server.log
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b5e541 and f6d6df4.

📒 Files selected for processing (6)
  • README.md (2 hunks)
  • examples/config.yaml (1 hunks)
  • webhook_server/app.py (3 hunks)
  • webhook_server/config/schema.yaml (1 hunks)
  • webhook_server/tests/test_logging_separation.py (1 hunks)
  • webhook_server/utils/helpers.py (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
webhook_server/utils/helpers.py (1)
webhook_server/libs/config.py (2)
  • get_value (99-120)
  • Config (11-142)
webhook_server/tests/test_logging_separation.py (2)
webhook_server/app.py (2)
  • get_log_viewer_controller (442-460)
  • lifespan (96-248)
webhook_server/utils/helpers.py (1)
  • get_log_file_path (95-114)
webhook_server/app.py (3)
webhook_server/utils/helpers.py (1)
  • get_logger_with_params (31-92)
webhook_server/libs/config.py (2)
  • Config (11-142)
  • get_value (99-120)
webhook_server/web/log_viewer.py (1)
  • LogViewerController (20-1005)
🪛 Ruff (0.14.5)
webhook_server/tests/test_logging_separation.py

13-13: Probable insecure usage of temporary file or directory: "/tmp/data"

(S108)


20-20: Probable insecure usage of temporary file or directory: "/tmp/data"

(S108)


24-24: Probable insecure usage of temporary file or directory: "/tmp/data/logs/server.log"

(S108)


25-25: Probable insecure usage of temporary file or directory: "/tmp/data/logs"

(S108)

🪛 YAMLlint (1.37.1)
webhook_server/config/schema.yaml

[error] 15-15: syntax error: mapping values are not allowed here

(syntax)

🔇 Additional comments (8)
examples/config.yaml (1)

5-6: LGTM! Clear documentation of new log file configuration options.

The example configuration properly demonstrates the new MCP and logs server log file settings with helpful comments indicating they support dynamic reload without server restart.

README.md (1)

229-230: LGTM! Documentation properly reflects new logging configuration.

The README updates consistently document the new log file options in both the Advanced Configuration and Monitoring sections, making them easy to discover for users.

Also applies to: 369-370

webhook_server/app.py (2)

127-144: LGTM! Proper implementation of MCP logging separation.

The MCP logging configuration correctly:

  1. Reads the config with appropriate default
  2. Creates a dedicated logger with file-specific configuration (rotation, masking)
  3. Copies handlers to prevent duplication issues
  4. Disables propagation to keep MCP logs out of webhook_server.log

The handler check (if mcp_file_logger.handlers:) is appropriate since get_logger_with_params always returns a logger with at least one handler (file or console).


453-459: LGTM! Log viewer controller initialization properly uses dedicated logger.

The singleton initialization correctly:

  1. Fetches the logs-server-log-file config with proper default
  2. Creates a dedicated logger for the log viewer
  3. Passes it to LogViewerController for isolated logging

This ensures logs server operations are separated from the main webhook processing logs.

webhook_server/utils/helpers.py (2)

31-93: LGTM! Clean implementation of log file configuration with proper path resolution.

The changes correctly:

  1. Add log_file_name parameter to support per-component log files
  2. Fall back to config's log-file when not explicitly provided
  3. Resolve paths using the new helper function
  4. Update cache key to use resolved path basename (ensuring single handler per file)

The implementation maintains backward compatibility while enabling the new logging separation feature.


95-115: LGTM! Robust log file path resolution with proper directory creation.

The helper function correctly:

  1. Handles absolute paths by returning them unchanged
  2. Resolves relative paths against data_dir/logs
  3. Creates the logs directory with exist_ok=True (safe for concurrent calls)
  4. Returns None for None input (explicit contracts)

The implementation is simple, correct, and handles all edge cases appropriately.

webhook_server/tests/test_logging_separation.py (1)

11-107: LGTM! Comprehensive test coverage for logging separation.

The tests properly verify:

  1. Path resolution (lines 11-31): Absolute, relative, and None cases
  2. MCP logging (lines 34-80): Configuration, handler attachment, and propagation disabling
  3. Log viewer initialization (lines 82-107): Dedicated logger creation and controller setup

The static analysis warnings about /tmp/data usage (S108) are expected for test code and can be safely ignored.

webhook_server/config/schema.yaml (1)

13-18: This is not a false positive—quote the description values to fix the YAML syntax error.

The YAML parser confirms a real syntax error at line 15, column 57. The issue is that description values contain unquoted colons (e.g., default: mcp_server.log), which YAML interprets as mapping syntax. Quote both description values:

  mcp-log-file:
    type: string
    description: "File path for the MCP log file (default: mcp_server.log)"
  logs-server-log-file:
    type: string
    description: "File path for the Logs Server log file (default: logs_server.log)"

Likely an incorrect or invalid review comment.

@myakove myakove merged commit 254fa97 into main Nov 20, 2025
7 of 9 checks passed
@myakove myakove deleted the feature/separate-logs branch November 20, 2025 11:50
@myakove-bot
Copy link
Collaborator

New container for ghcr.io/myk-org/github-webhook-server:latest published

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