Skip to content

Commit

Permalink
Remove deprecated support to bolding log text with positional boolean…
Browse files Browse the repository at this point in the history
… in `ActiveSupport::LogSubscriber#color`
  • Loading branch information
rafaelfranca committed May 1, 2024
1 parent 75981ad commit c4fdfc5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
4 changes: 4 additions & 0 deletions activesupport/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Remove deprecated support to bolding log text with positional boolean in `ActiveSupport::LogSubscriber#color`.

*Rafael Mendonça França*

* Remove deprecated constants `ActiveSupport::LogSubscriber::CLEAR` and `ActiveSupport::LogSubscriber::BOLD`.

*Rafael Mendonça França*
Expand Down
8 changes: 0 additions & 8 deletions activesupport/lib/active_support/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,6 @@ def color(text, color, mode_options = {}) # :doc:
end

def mode_from(options)
if options.is_a?(TrueClass) || options.is_a?(FalseClass)
ActiveSupport.deprecator.warn(<<~MSG.squish)
Bolding log text with a positional boolean is deprecated and will be removed
in Rails 7.2. Use an option hash instead (eg. `color("my text", :red, bold: true)`).
MSG
options = { bold: options }
end

modes = MODES.values_at(*options.compact_blank.keys)

"\e[#{modes.join(";")}m" if modes.any?
Expand Down
11 changes: 0 additions & 11 deletions activesupport/test/log_subscriber_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ def baz(event)
info "#{color("rad", :green, bold: true, underline: true)}, #{color("isn't it?", :yellow, italic: true)}"
end

def deprecated(event)
info "#{color("bogus", :red, true)}"
end

def puke(event)
raise "puke"
end
Expand Down Expand Up @@ -71,13 +67,6 @@ def test_set_mode_for_messages
assert_equal "\e[1;4m\e[32mrad\e[0m, \e[3m\e[33misn't it?\e[0m", @logger.logged(:info).last
end

def test_deprecated_bold_format_for_messages
ActiveSupport::LogSubscriber.colorize_logging = true
assert_deprecated(ActiveSupport.deprecator) do
@log_subscriber.deprecated(nil)
end
end

def test_does_not_set_color_if_colorize_logging_is_set_to_false
@log_subscriber.bar(nil)
assert_equal "cool, isn't it?", @logger.logged(:info).last
Expand Down
2 changes: 2 additions & 0 deletions guides/source/7_2_release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ Please refer to the [Changelog][active-support] for detailed changes.

* Remove deprecated constants `ActiveSupport::LogSubscriber::CLEAR` and `ActiveSupport::LogSubscriber::BOLD`.

* Remove deprecated support to bolding log text with positional boolean in `ActiveSupport::LogSubscriber#color`.

* Remove deprecated support for the pre-Ruby 2.4 behavior of `to_time` returning a `Time` object with local timezone.

### Deprecations
Expand Down

0 comments on commit c4fdfc5

Please sign in to comment.