Skip to content

Build and pass tags as options to logger#15

Merged
ioquatix merged 2 commits intosocketry:mainfrom
HolyWalley:support-tagged-logging
Apr 4, 2026
Merged

Build and pass tags as options to logger#15
ioquatix merged 2 commits intosocketry:mainfrom
HolyWalley:support-tagged-logging

Conversation

@HolyWalley
Copy link
Copy Markdown
Contributor

@HolyWalley HolyWalley commented Sep 2, 2025

Issue
This is one of 2 changes needed to support the use of Rails.logger.tagged (another part)

This only works with hash type tags, e.g. Rails.logger.tagged({ request_id: 137 })

Types of Changes

  • New feature.

Contribution

Comment thread gems.rb Outdated
Comment thread gems.rb
gem "bake-test-external"

gem "sqlite3", "~> 1.4"
gem "sqlite3", ">= 1.4"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this way it works with rails 8.0+

@HolyWalley HolyWalley marked this pull request as ready for review September 8, 2025 09:44
@ioquatix
Copy link
Copy Markdown
Member

ioquatix commented Dec 9, 2025

Apologies for the late review.

I've just released v0.5 which fixes compatibility with Rails thanks to @jasl

Do you mind rebasing this?

@HolyWalley HolyWalley force-pushed the support-tagged-logging branch from 1932457 to c6ab122 Compare December 10, 2025 09:24
@HolyWalley
Copy link
Copy Markdown
Contributor Author

Hey @ioquatix
done

@HolyWalley
Copy link
Copy Markdown
Contributor Author

I'll check and fix red CI a bit later, sorry :(

@HolyWalley
Copy link
Copy Markdown
Contributor Author

@ioquatix sorry it took extremely long
The jruby and coverage fails on main, so, I'm not fixing it here

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

Adds support for propagating Rails.logger.tagged hash tags into Console log entries by converting tag hashes into keyword options passed to the underlying Console logger, enabling structured log context (e.g., request_id) to appear as fields.

Changes:

  • Merge ActiveSupport::TaggedLogging tag hashes into log payload options in Console::Adapter::Rails::Logger#add.
  • Add tests validating hash tag propagation and ensuring string tags don’t break logging.
  • Bump console gem dependency to a newer version to support the new keyword-options behavior.

Reviewed changes

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

File Description
lib/console/adapter/rails/logger.rb Builds an options hash from Rails tag stack and forwards it as keyword options to Console logging.
test/console/adapter/rails/logger.rb Adds coverage for hash tags being logged as fields and string tags being ignored safely.
console-adapter-rails.gemspec Updates console dependency requirement to a newer minor series.

Comment thread lib/console/adapter/rails/logger.rb Outdated
Comment thread lib/console/adapter/rails/logger.rb Outdated
Comment thread test/console/adapter/rails/logger.rb Outdated
@ioquatix ioquatix force-pushed the support-tagged-logging branch from db9d748 to a4bd0c5 Compare April 4, 2026 21:35
@ioquatix ioquatix force-pushed the support-tagged-logging branch from a4bd0c5 to c7673d2 Compare April 4, 2026 21:40
@ioquatix ioquatix merged commit c7673d2 into socketry:main Apr 4, 2026
18 of 20 checks passed
@ioquatix ioquatix added this to the v0.6.0 milestone Apr 4, 2026
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.

3 participants