Skip to content

Conversation

@ndbroadbent
Copy link
Member

Summary

  • Fixed the TaggedLogging formatter monkey patch to check LogStruct.enabled? before wrapping messages in hashes
  • When LogStruct is disabled (default in development), log messages now preserve their original Rails format

Problem

When adding the LogStruct gem to a Rails 8.1 app without any configuration, development logs were appearing as {message: "..."} instead of plain text. This was because the FormatterExtension monkey patch was unconditionally wrapping all string messages in hashes, regardless of whether LogStruct was enabled.

Solution

Added an early return check in the FormatterExtension#call method to skip hash wrapping when LogStruct is disabled, preserving the original Rails logging behavior in development.

Test plan

  • Added unit tests for the TaggedLogging formatter conditional behavior
  • Added configuration test for development server scenario
  • All existing Ruby tests pass
  • All Rails integration tests pass
  • Typecheck passes
  • Lint passes

Fixes #1

🤖 Generated with Claude Code

The TaggedLogging formatter monkey patch was unconditionally wrapping
all string log messages in hashes, even when LogStruct was disabled.
This caused development logs to appear as {message: "..."} instead of
plain text.

Added an early return check to preserve original Rails logging behavior
when LogStruct is disabled.

Fixes #1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ndbroadbent ndbroadbent merged commit 5d6427b into main Nov 30, 2025
6 checks passed
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.

Development logs in a Rails 8.1 app

2 participants