Skip to content

chore: improved logging infra and added 'component', 'containerId' and 'event'#48

Merged
DeepSpace2 merged 2 commits into
masterfrom
chore-improved-logging-infra
Jun 6, 2026
Merged

chore: improved logging infra and added 'component', 'containerId' and 'event'#48
DeepSpace2 merged 2 commits into
masterfrom
chore-improved-logging-infra

Conversation

@DeepSpace2

@DeepSpace2 DeepSpace2 commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Refactor

    • Moved to component-scoped named loggers for clearer log attribution.
    • Added context-based logger propagation for request/container-scoped logging.
  • New Features

    • Added a utility to produce consistent short Docker container IDs (12-char truncation).

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: caaca24c-079a-4fe7-99ee-06ec4a86dd1d

📥 Commits

Reviewing files that changed from the base of the PR and between 4298cf3 and 89055e5.

📒 Files selected for processing (3)
  • main.go
  • pkg/clients/clients.go
  • pkg/config/config.go
✅ Files skipped from review due to trivial changes (3)
  • pkg/clients/clients.go
  • main.go
  • pkg/config/config.go

📝 Walkthrough

Walkthrough

This PR adds component-scoped named loggers and context-based logger propagation, migrates package-level loggers to component names, adds a Docker container ID truncation helper, and refactors processor handlers to receive and use context-propagated loggers.

Changes

Component-scoped logging with context propagation

Layer / File(s) Summary
Logging API: component-scoped loggers and context helpers
pkg/logging/log.go
Core logging package refactored to accept a component name in GetLogger(component string), attach it as a structured component field, and introduce WithLogger(ctx, logger) and FromContext(ctx) helpers for context-based logger propagation with fallback to global logger.
Package logger migrations to named loggers
main.go, pkg/clients/clients.go, pkg/clients/docker/docker.go, pkg/clients/npm/npm.go, pkg/clients/adguardhome/adguardhome.go, pkg/clients/pihole/pihole.go, pkg/config/config.go, e2e_tests/e2e_test.go
Package-level loggers updated to call GetLogger() with explicit component names (e.g., "main", "clients", "docker", "npm", "adguardhome", "pihole", "config", "e2e").
Docker container ID truncation utility
pkg/clients/docker/docker.go
Adds GetShortContainerId(containerId string) to Docker client; returns the input unchanged if shorter than 12 characters, otherwise truncates to the first 12 characters.
Processor context-scoped logging and handler refactoring
pkg/processor/processor.go
Processor initializes named logger and refactors DNS handler functions (handleAdguardHome, handlePiHole, handleNpm) to accept ctx and derive loggers via FromContext(ctx). processContainer now creates a scoped logger with host/container fields, uses WithLogger to attach it to ctx, updates dry-run logs to include ip, port, and urls, and removes explicit "host"/"container" fields from handler log calls.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: it references improved logging infrastructure, addition of component-scoped logging, and the new GetShortContainerId helper that provides container ID truncation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@DeepSpace2
DeepSpace2 merged commit 869267e into master Jun 6, 2026
8 checks passed
@DeepSpace2
DeepSpace2 deleted the chore-improved-logging-infra branch June 6, 2026 08:54
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.

1 participant