diff --git a/.github/workflows/test-external.yaml b/.github/workflows/test-external.yaml index 23aa4b1..9ec63e2 100644 --- a/.github/workflows/test-external.yaml +++ b/.github/workflows/test-external.yaml @@ -17,9 +17,9 @@ jobs: - macos ruby: - - "3.2" - "3.3" - "3.4" + - "4.0" steps: - uses: actions/checkout@v6 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 56bbeec..e91d97c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -18,9 +18,9 @@ jobs: - macos ruby: - - "3.2" - "3.3" - "3.4" + - "4.0" experimental: [false] diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000..f6117aa --- /dev/null +++ b/.mailmap @@ -0,0 +1 @@ +Yasha Krasnou diff --git a/.rubocop.yml b/.rubocop.yml index 4766d62..0eeddec 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -82,6 +82,25 @@ Layout/SpaceAroundBlockParameters: Enabled: true EnforcedStyleInsidePipes: no_space +Layout/FirstArrayElementIndentation: + Enabled: true + EnforcedStyle: consistent + +Layout/ArrayAlignment: + Enabled: true + EnforcedStyle: with_fixed_indentation + +Layout/FirstArgumentIndentation: + Enabled: true + EnforcedStyle: consistent + +Layout/ArgumentAlignment: + Enabled: true + EnforcedStyle: with_fixed_indentation + +Layout/ClosingParenthesisIndentation: + Enabled: true + Style/FrozenStringLiteralComment: Enabled: true diff --git a/bake.rb b/bake.rb index b40b87d..9441211 100644 --- a/bake.rb +++ b/bake.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2025, by Samuel Williams. +# Copyright, 2025-2026, by Samuel Williams. # Update the project documentation with the new version number. # @@ -10,3 +10,10 @@ def after_gem_release_version_increment(version) context["releases:update"].call(version) context["utopia:project:update"].call end + +# Create a GitHub release for the given tag. +# +# @parameter tag [String] The tag to create a release for. +def after_gem_release(tag:, **options) + context["releases:github:release"].call(tag) +end diff --git a/config/sus.rb b/config/sus.rb index 80f31f4..4f7b9fe 100644 --- a/config/sus.rb +++ b/config/sus.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2023, by Samuel Williams. +# Copyright, 2023-2026, by Samuel Williams. require "covered/sus" include Covered::Sus diff --git a/console-adapter-rails.gemspec b/console-adapter-rails.gemspec index 996923b..727e49e 100644 --- a/console-adapter-rails.gemspec +++ b/console-adapter-rails.gemspec @@ -7,7 +7,7 @@ Gem::Specification.new do |spec| spec.version = Console::Adapter::Rails::VERSION spec.summary = "Adapt Rails logs and events to the console gem." - spec.authors = ["Samuel Williams", "Joshua Young", "Jun Jiang", "Michael Adams"] + spec.authors = ["Samuel Williams", "Joshua Young", "Jun Jiang", "Michael Adams", "Yasha Krasnou"] spec.license = "MIT" spec.cert_chain = ["release.cert"] @@ -22,9 +22,9 @@ Gem::Specification.new do |spec| spec.files = Dir.glob(["{context,lib}/**/*", "*.md"], File::FNM_DOTMATCH, base: __dir__) - spec.required_ruby_version = ">= 3.2" + spec.required_ruby_version = ">= 3.3" - spec.add_dependency "console", "~> 1.21" + spec.add_dependency "console", "~> 1.34" spec.add_dependency "fiber-storage", "~> 1.0" spec.add_dependency "rails", ">= 7.0" end diff --git a/fixtures/app.rb b/fixtures/app.rb index 2a02e3b..41a6659 100644 --- a/fixtures/app.rb +++ b/fixtures/app.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2023-2024, by Samuel Williams. +# Copyright, 2023-2026, by Samuel Williams. # Copyright, 2024, by Michael Adams. require "rails" diff --git a/gems/rails-v7.rb b/gems/rails-v7.rb index b2c6a0b..5869011 100644 --- a/gems/rails-v7.rb +++ b/gems/rails-v7.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2023-2024, by Samuel Williams. +# Copyright, 2023-2026, by Samuel Williams. eval_gemfile("../gems.rb") diff --git a/gems/rails-v8.rb b/gems/rails-v8.rb index f4fecf7..699454a 100644 --- a/gems/rails-v8.rb +++ b/gems/rails-v8.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2023-2024, by Samuel Williams. +# Copyright, 2023-2026, by Samuel Williams. # Copyright, 2025, by Jun Jiang. eval_gemfile("../gems.rb") diff --git a/lib/console/adapter/rails.rb b/lib/console/adapter/rails.rb index 291485d..4d182b6 100644 --- a/lib/console/adapter/rails.rb +++ b/lib/console/adapter/rails.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2023-2024, by Samuel Williams. +# Copyright, 2023-2026, by Samuel Williams. # Copyright, 2024, by Michael Adams. require_relative "rails/logger" diff --git a/lib/console/adapter/rails/logger.rb b/lib/console/adapter/rails/logger.rb index c775a4d..78a608d 100644 --- a/lib/console/adapter/rails/logger.rb +++ b/lib/console/adapter/rails/logger.rb @@ -3,6 +3,7 @@ # Released under the MIT License. # Copyright, 2023-2025, by Samuel Williams. # Copyright, 2024, by Michael Adams. +# Copyright, 2026, by Yasha Krasnou. require "console/compatible/logger" @@ -83,7 +84,25 @@ def silenced?(severity) def add(severity, message = nil, progname = nil, &block) return if silenced?(severity) - super(severity, message, progname, &block) + if formatter.respond_to?(:tag_stack) + tags = formatter.tag_stack.tags + + options = tags.each_with_object({}) do |tag, memo| + next unless tag.respond_to?(:to_hash) + + tag.to_hash.each do |key, value| + case key + when Symbol + memo[key] = value + else + next unless key.respond_to?(:to_sym) + memo[key.to_sym] = value + end + end + end + end + + super(severity, message, progname, **options, &block) end # Configure Rails to use the Console logger. diff --git a/lib/console/adapter/rails/railtie.rb b/lib/console/adapter/rails/railtie.rb index 75262bd..3f36de4 100644 --- a/lib/console/adapter/rails/railtie.rb +++ b/lib/console/adapter/rails/railtie.rb @@ -2,7 +2,7 @@ # Released under the MIT License. # Copyright, 2024, by Michael Adams. -# Copyright, 2024, by Samuel Williams. +# Copyright, 2024-2026, by Samuel Williams. # Copyright, 2025, by Jun Jiang. require "action_controller/log_subscriber" diff --git a/license.md b/license.md index 22bfaa6..0783158 100644 --- a/license.md +++ b/license.md @@ -1,9 +1,10 @@ # MIT License -Copyright, 2023-2025, by Samuel Williams. +Copyright, 2023-2026, by Samuel Williams. Copyright, 2023, by Joshua Young. Copyright, 2024, by Michael Adams. Copyright, 2025, by Jun Jiang. +Copyright, 2026, by Yasha Krasnou. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/readme.md b/readme.md index 9db19cd..daf72ba 100644 --- a/readme.md +++ b/readme.md @@ -28,6 +28,22 @@ We welcome contributions to this project. 4. Push to the branch (`git push origin my-new-feature`). 5. Create new Pull Request. +### Running Tests + +To run the test suite: + +``` shell +bundle exec sus +``` + +### Making Releases + +To make a new release: + +``` shell +bundle exec bake gem:release:patch # or minor or major +``` + ### Developer Certificate of Origin In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed. diff --git a/test/console/adapter/rails/action_controller.rb b/test/console/adapter/rails/action_controller.rb index 7508d90..b34780f 100644 --- a/test/console/adapter/rails/action_controller.rb +++ b/test/console/adapter/rails/action_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2023, by Samuel Williams. +# Copyright, 2023-2026, by Samuel Williams. require "app" require "console/capture" diff --git a/test/console/adapter/rails/active_record.rb b/test/console/adapter/rails/active_record.rb index 45b625e..8805c65 100644 --- a/test/console/adapter/rails/active_record.rb +++ b/test/console/adapter/rails/active_record.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2023-2024, by Samuel Williams. +# Copyright, 2023-2026, by Samuel Williams. # Copyright, 2024, by Michael Adams. require "app" diff --git a/test/console/adapter/rails/logger.rb b/test/console/adapter/rails/logger.rb index e1249e6..1723461 100644 --- a/test/console/adapter/rails/logger.rb +++ b/test/console/adapter/rails/logger.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2023-2024, by Samuel Williams. +# Copyright, 2023-2026, by Samuel Williams. # Copyright, 2024, by Michael Adams. +# Copyright, 2026, by Yasha Krasnou. require "app" require "console/capture" @@ -21,6 +22,54 @@ def before expect(Rails.logger).to be(:respond_to?, :tagged) end + it "should log tags that are Hashes" do + Rails.logger.tagged({ foo: "bar" }) do + Rails.logger.info("Hello World") + end + + expect(capture.last).to have_keys( + message: be == "Hello World", + foo: be == "bar" + ) + end + + it "should not fail when logging string tags" do + Rails.logger.tagged("foo=bar") do + Rails.logger.info("Hello World") + end + + expect(capture.last).to have_keys( + message: be == "Hello World" + ) + + expect(capture.last).not.to have_keys(:foo) + expect(capture.last).not.to have_keys("foo=bar") + end + + it "should symbolize string-keyed hash tags" do + Rails.logger.tagged({ "request_id" => "abc" }) do + Rails.logger.info("Hello World") + end + + expect(capture.last).to have_keys( + message: be == "Hello World", + request_id: be == "abc" + ) + expect(capture.last).not.to have_keys("request_id") + end + + it "should symbolize HashWithIndifferentAccess tags" do + Rails.logger.tagged(ActiveSupport::HashWithIndifferentAccess.new(request_id: "xyz")) do + Rails.logger.info("Hello World") + end + + expect(capture.last).to have_keys( + message: be == "Hello World", + request_id: be == "xyz" + ) + expect(capture.last).not.to have_keys("request_id") + end + it "should support silence" do expect(Rails.logger).to be(:respond_to?, :silence)