diff options
-rw-r--r-- | activesupport/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/logger_silence.rb | 37 | ||||
-rw-r--r-- | activesupport/test/broadcast_logger_test.rb | 10 | ||||
-rw-r--r-- | guides/source/asset_pipeline.md | 5 | ||||
-rw-r--r-- | guides/source/command_line.md | 5 | ||||
-rw-r--r-- | guides/source/configuring.md | 4 | ||||
-rw-r--r-- | guides/source/generators.md | 5 | ||||
-rw-r--r-- | guides/source/getting_started.md | 3 | ||||
-rw-r--r-- | guides/source/working_with_javascript_in_rails.md | 4 |
9 files changed, 46 insertions, 31 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index c63e00d59c..586ed28693 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -3,6 +3,10 @@ *Gannon McGibbon* +* Deprecate the use of `LoggerSilence` in favor of `ActiveSupport::LoggerSilence` + + *Edouard Chin* + * Deprecate using negative limits in `String#first` and `String#last`. *Gannon McGibbon*, *Eric Turner* diff --git a/activesupport/lib/active_support/logger_silence.rb b/activesupport/lib/active_support/logger_silence.rb index 4344ca0429..2f62cc13b9 100644 --- a/activesupport/lib/active_support/logger_silence.rb +++ b/activesupport/lib/active_support/logger_silence.rb @@ -7,22 +7,37 @@ module LoggerSilence extend ActiveSupport::Concern included do - cattr_accessor :silencer, default: true + ActiveSupport::Deprecation.warn( + "Including LoggerSilence is deprecated and will be removed in Rails 6.1. " \ + "Please use `ActiveSupport::LoggerSilence` instead" + ) + + include ActiveSupport::LoggerSilence end +end + +module ActiveSupport + module LoggerSilence + extend ActiveSupport::Concern + + included do + cattr_accessor :silencer, default: true + end - # Silences the logger for the duration of the block. - def silence(temporary_level = Logger::ERROR) - if silencer - begin - old_local_level = local_level - self.local_level = temporary_level + # Silences the logger for the duration of the block. + def silence(temporary_level = Logger::ERROR) + if silencer + begin + old_local_level = local_level + self.local_level = temporary_level + yield self + ensure + self.local_level = old_local_level + end + else yield self - ensure - self.local_level = old_local_level end - else - yield self end end end diff --git a/activesupport/test/broadcast_logger_test.rb b/activesupport/test/broadcast_logger_test.rb index 181113e70a..ea2e388b8f 100644 --- a/activesupport/test/broadcast_logger_test.rb +++ b/activesupport/test/broadcast_logger_test.rb @@ -114,6 +114,14 @@ module ActiveSupport assert_equal [[::Logger::FATAL, "seen", nil]], log2.adds end + test "Including top constant LoggerSilence is deprecated" do + assert_deprecated("Please use `ActiveSupport::LoggerSilence`") do + logger = Class.new(CustomLogger) do + include ::LoggerSilence + end + end + end + class CustomLogger attr_reader :adds, :closed, :chevrons attr_accessor :level, :progname, :formatter, :local_level @@ -166,7 +174,7 @@ module ActiveSupport end class FakeLogger < CustomLogger - include LoggerSilence + include ActiveSupport::LoggerSilence end end end diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md index bf046a3341..66cf9da33b 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -184,9 +184,8 @@ the file `scaffolds.css` (or `scaffolds.scss` if `sass-rails` is in the `Gemfile`.) For example, if you generate a `ProjectsController`, Rails will also add a new -file at `app/assets/javascripts/projects.coffee` and another at -`app/assets/stylesheets/projects.scss`. By default these files will be ready -to use by your application immediately using the `require_tree` directive. See +file at `app/assets/stylesheets/projects.scss`. By default these files will be +ready to use by your application immediately using the `require_tree` directive. See [Manifest Files and Directives](#manifest-files-and-directives) for more details on require_tree. diff --git a/guides/source/command_line.md b/guides/source/command_line.md index 7fa0a49203..5fd3ad17de 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -185,7 +185,7 @@ The controller generator is expecting parameters in the form of `generate contro ```bash $ rails generate controller Greetings hello create app/controllers/greetings_controller.rb - route get "greetings/hello" + route get 'greetings/hello' invoke erb create app/views/greetings create app/views/greetings/hello.html.erb @@ -193,9 +193,8 @@ $ rails generate controller Greetings hello create test/controllers/greetings_controller_test.rb invoke helper create app/helpers/greetings_helper.rb + invoke test_unit invoke assets - invoke coffee - create app/assets/javascripts/greetings.coffee invoke scss create app/assets/stylesheets/greetings.scss ``` diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 18a377a02e..d23af2ca57 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -119,12 +119,12 @@ defaults to `:debug` for all environments. The available log levels are: `:debug * `config.logger` is the logger that will be used for `Rails.logger` and any related Rails logging such as `ActiveRecord::Base.logger`. It defaults to an instance of `ActiveSupport::TaggedLogging` that wraps an instance of `ActiveSupport::Logger` which outputs a log to the `log/` directory. You can supply a custom logger, to get full compatibility you must follow these guidelines: * To support a formatter, you must manually assign a formatter from the `config.log_formatter` value to the logger. * To support tagged logs, the log instance must be wrapped with `ActiveSupport::TaggedLogging`. - * To support silencing, the logger must include `LoggerSilence` and `ActiveSupport::LoggerThreadSafeLevel` modules. The `ActiveSupport::Logger` class already includes these modules. + * To support silencing, the logger must include `ActiveSupport::LoggerSilence` and `ActiveSupport::LoggerThreadSafeLevel` modules. The `ActiveSupport::Logger` class already includes these modules. ```ruby class MyLogger < ::Logger include ActiveSupport::LoggerThreadSafeLevel - include LoggerSilence + include ActiveSupport::LoggerSilence end mylogger = MyLogger.new(STDOUT) diff --git a/guides/source/generators.md b/guides/source/generators.md index 89424a161b..f028d14998 100644 --- a/guides/source/generators.md +++ b/guides/source/generators.md @@ -203,8 +203,6 @@ $ rails generate scaffold User name:string create test/application_system_test_case.rb create test/system/users_test.rb invoke assets - invoke coffee - create app/assets/javascripts/users.coffee invoke scss create app/assets/stylesheets/users.scss invoke scss @@ -426,9 +424,8 @@ $ rails generate scaffold Comment body:text create test/application_system_test_case.rb create test/system/comments_test.rb invoke assets - invoke coffee - create app/assets/javascripts/comments.coffee invoke scss + create app/assets/stylesheets/scaffolds.scss ``` Fallbacks allow your generators to have a single responsibility, increasing code reuse and reducing the amount of duplication. diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 197a198db7..9eb77d2a50 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -272,8 +272,6 @@ invoke helper create app/helpers/welcome_helper.rb invoke test_unit invoke assets -invoke coffee -create app/assets/javascripts/welcome.coffee invoke scss create app/assets/stylesheets/welcome.scss ``` @@ -1665,7 +1663,6 @@ This creates five files and one empty directory: | app/views/comments/ | Views of the controller are stored here | | test/controllers/comments_controller_test.rb | The test for the controller | | app/helpers/comments_helper.rb | A view helper file | -| app/assets/javascripts/comments.coffee | CoffeeScript for the controller | | app/assets/stylesheets/comments.scss | Cascading style sheet for the controller | Like with any blog, our readers will create their comments directly after diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index 36f5039883..c36b3faa6c 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -494,10 +494,6 @@ replace the entire `<body>` of the page with the `<body>` of the response. It will then use PushState to change the URL to the correct one, preserving refresh semantics and giving you pretty URLs. -The only thing you have to do to enable Turbolinks is have it in your `Gemfile`, -and put `//= require turbolinks` in your JavaScript manifest, which is usually -`app/assets/javascripts/application.js`. - If you want to disable Turbolinks for certain links, add a `data-turbolinks="false"` attribute to the tag: |