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

This commit is contained in:
Rafael Mendonça França 2024-01-09 23:42:06 +00:00
parent 75981ade29
commit c4fdfc55fa
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
4 changed files with 6 additions and 19 deletions

@ -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*

@ -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?

@ -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
@ -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

@ -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