Skip to content

fix: [CN-70] require JSON processors in log handlers#67

Merged
vpakhuchyi merged 1 commit intomainfrom
CN-70-log-handlers-allow-non-json-censor-instances
Nov 17, 2025
Merged

fix: [CN-70] require JSON processors in log handlers#67
vpakhuchyi merged 1 commit intomainfrom
CN-70-log-handlers-allow-non-json-censor-instances

Conversation

@vpakhuchyi
Copy link
Copy Markdown
Owner

Pull request

Link to the related ticket

https://censor.atlassian.net/browse/CN-70

Description of changes

  • add Processor.OutputFormat so integrations can inspect the active encoder
  • guard zerolog, zap, and slog handlers against text-mode processors
  • document the JSON requirement and cover panic paths with regression tests

Checklist

Please ensure that your pull request complies with the following requirements:

  • The changes have been tested locally (if applicable).
  • The documentation has been updated (if applicable).

- add Processor.OutputFormat so integrations can inspect the active encoder
- guard zerolog, zap, and slog handlers against text-mode processors
- document the JSON requirement and cover panic paths with regression tests
Copilot AI review requested due to automatic review settings November 17, 2025 22:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds validation to ensure log handlers only accept JSON-mode processors, preventing runtime issues when text-mode processors are used with structured logging frameworks.

  • Introduces OutputFormat() method on Processor to expose the configured output format
  • Adds runtime checks in zerolog, zap, and slog handlers that panic if a text-mode processor is provided
  • Includes comprehensive test coverage for the new validation logic

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
processor.go Adds OutputFormat() method to expose processor configuration; refactors string literal to use constant
processor_test.go Adds test coverage for OutputFormat() method including nil processor panic case
handlers/zerolog/handler.go Adds validation to panic if text-mode processor is used; updates function signature to use any instead of interface{}
handlers/zerolog/handler_test.go Adds regression test for text-mode processor panic scenario; fixes indentation in existing test
handlers/zerolog/doc.go Documents JSON requirement for processors
handlers/zap/handler.go Adds validation to panic if text-mode processor is used
handlers/zap/handler_test.go Adds regression test for text-mode processor panic scenario
handlers/zap/doc.go Documents JSON requirement for processors
handlers/slog/handler.go Adds validation to panic if text-mode processor is used
handlers/slog/handler_test.go Adds regression test for text-mode processor panic scenario
handlers/slog/doc.go Documents JSON requirement; updates example email address for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vpakhuchyi vpakhuchyi merged commit e561f42 into main Nov 17, 2025
12 checks passed
@vpakhuchyi vpakhuchyi deleted the CN-70-log-handlers-allow-non-json-censor-instances branch November 17, 2025 22:37
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.

2 participants