diff options
-rw-r--r--[-rwxr-xr-x] | activemodel/lib/active_model/serializers/xml.rb | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | activemodel/test/cases/serializers/xml_serialization_test.rb | 0 | ||||
-rw-r--r-- | activesupport/lib/active_support/buffered_logger.rb | 18 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/thread.rb | 6 | ||||
-rw-r--r-- | activesupport/test/configurable_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/dependencies_test.rb | 10 | ||||
-rw-r--r-- | activesupport/test/deprecation/buffered_logger_test.rb | 22 | ||||
-rw-r--r-- | guides/source/configuring.md | 6 | ||||
-rw-r--r-- | guides/source/debugging_rails_applications.md | 2 | ||||
-rw-r--r-- | guides/source/performance_testing.md | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/gitignore | 7 |
11 files changed, 55 insertions, 20 deletions
diff --git a/activemodel/lib/active_model/serializers/xml.rb b/activemodel/lib/active_model/serializers/xml.rb index 648ae7ce3d..648ae7ce3d 100755..100644 --- a/activemodel/lib/active_model/serializers/xml.rb +++ b/activemodel/lib/active_model/serializers/xml.rb diff --git a/activemodel/test/cases/serializers/xml_serialization_test.rb b/activemodel/test/cases/serializers/xml_serialization_test.rb index 99a9c1fe33..99a9c1fe33 100755..100644 --- a/activemodel/test/cases/serializers/xml_serialization_test.rb +++ b/activemodel/test/cases/serializers/xml_serialization_test.rb diff --git a/activesupport/lib/active_support/buffered_logger.rb b/activesupport/lib/active_support/buffered_logger.rb index 0595446189..1cd0c2f790 100644 --- a/activesupport/lib/active_support/buffered_logger.rb +++ b/activesupport/lib/active_support/buffered_logger.rb @@ -2,6 +2,20 @@ require 'active_support/deprecation' require 'active_support/logger' module ActiveSupport - BufferedLogger = ActiveSupport::Deprecation::DeprecatedConstantProxy.new( - 'BufferedLogger', '::ActiveSupport::Logger') + class BufferedLogger < Logger + + def initialize(*args) + self.class._deprecation_warning + super + end + + def self.inherited(*) + _deprecation_warning + super + end + + def self._deprecation_warning + ::ActiveSupport::Deprecation.warn 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.' + end + end end diff --git a/activesupport/lib/active_support/core_ext/thread.rb b/activesupport/lib/active_support/core_ext/thread.rb index 6ad0b2d69c..5481766f10 100644 --- a/activesupport/lib/active_support/core_ext/thread.rb +++ b/activesupport/lib/active_support/core_ext/thread.rb @@ -65,6 +65,10 @@ class Thread private def locals - @locals || LOCK.synchronize { @locals ||= {} } + if defined?(@locals) + @locals + else + LOCK.synchronize { @locals ||= {} } + end end end unless Thread.instance_methods.include?(:thread_variable_set) diff --git a/activesupport/test/configurable_test.rb b/activesupport/test/configurable_test.rb index 215a6e06b0..d00273a028 100644 --- a/activesupport/test/configurable_test.rb +++ b/activesupport/test/configurable_test.rb @@ -38,7 +38,7 @@ class ConfigurableActiveSupport < ActiveSupport::TestCase assert_equal :bar, Parent.config.foo end - test "configuration accessors is not available on instance" do + test "configuration accessors are not available on instance" do instance = Parent.new assert !instance.respond_to?(:bar) diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 51a7e4b2fe..9d913c27b0 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -923,10 +923,8 @@ class DependenciesTest < ActiveSupport::TestCase def test_remove_constant_does_not_autoload_already_removed_parents_as_a_side_effect with_autoloading_fixtures do - silence_warnings do - ::A - ::A::B - end + _ = ::A # assignment to silence parse-time warning "possibly useless use of :: in void context" + _ = ::A::B # assignment to silence parse-time warning "possibly useless use of :: in void context" ActiveSupport::Dependencies.remove_constant('A') ActiveSupport::Dependencies.remove_constant('A::B') assert !defined?(A) @@ -936,9 +934,7 @@ class DependenciesTest < ActiveSupport::TestCase def test_load_once_constants_should_not_be_unloaded with_autoloading_fixtures do ActiveSupport::Dependencies.autoload_once_paths = ActiveSupport::Dependencies.autoload_paths - silence_warnings do - ::A - end + _ = ::A # assignment to silence parse-time warning "possibly useless use of :: in void context" assert defined?(A) ActiveSupport::Dependencies.clear assert defined?(A) diff --git a/activesupport/test/deprecation/buffered_logger_test.rb b/activesupport/test/deprecation/buffered_logger_test.rb new file mode 100644 index 0000000000..bf11a4732c --- /dev/null +++ b/activesupport/test/deprecation/buffered_logger_test.rb @@ -0,0 +1,22 @@ +require 'abstract_unit' +require 'active_support/buffered_logger' + +class BufferedLoggerTest < ActiveSupport::TestCase + + def test_can_be_subclassed + warn = 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.' + + ActiveSupport::Deprecation.expects(:warn).with(warn).once + + Class.new(ActiveSupport::BufferedLogger) + end + + def test_issues_deprecation_when_instantiated + warn = 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.' + + ActiveSupport::Deprecation.expects(:warn).with(warn).once + + ActiveSupport::BufferedLogger.new(STDOUT) + end + +end diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 6dba76c7b2..6e93932d49 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -105,7 +105,7 @@ These configuration methods are to be called on a `Rails::Railtie` object, such * `config.log_tags` accepts a list of methods that respond to `request` object. This makes it easy to tag log lines with debug information like subdomain and request id — both very helpful in debugging multi-user production applications. -* `config.logger` accepts a logger conforming to the interface of Log4r or the default Ruby `Logger` class. Defaults to an instance of `ActiveSupport::BufferedLogger`, with auto flushing off in production mode. +* `config.logger` accepts a logger conforming to the interface of Log4r or the default Ruby `Logger` class. Defaults to an instance of `ActiveSupport::Logger`, with auto flushing off in production mode. * `config.middleware` allows you to configure the application's middleware. This is covered in depth in the [Configuring Middleware](#configuring-middleware) section below. @@ -437,7 +437,7 @@ There are a few configuration options available in Active Support: * `config.active_support.use_standard_json_time_format` enables or disables serializing dates to ISO 8601 format. Defaults to `true`. -* `ActiveSupport::BufferedLogger.silencer` is set to `false` to disable the ability to silence logging in a block. The default is `true`. +* `ActiveSupport::Logger.silencer` is set to `false` to disable the ability to silence logging in a block. The default is `true`. * `ActiveSupport::Cache::Store.logger` specifies the logger to use within cache store operations. @@ -637,7 +637,7 @@ Below is a comprehensive list of all the initializers found in Rails in the orde * `load_active_support` Requires `active_support/dependencies` which sets up the basis for Active Support. Optionally requires `active_support/all` if `config.active_support.bare` is un-truthful, which is the default. -* `initialize_logger` Initializes the logger (an `ActiveSupport::BufferedLogger` object) for the application and makes it accessible at `Rails.logger`, provided that no initializer inserted before this point has defined `Rails.logger`. +* `initialize_logger` Initializes the logger (an `ActiveSupport::Logger` object) for the application and makes it accessible at `Rails.logger`, provided that no initializer inserted before this point has defined `Rails.logger`. * `initialize_cache` If `Rails.cache` isn't set yet, initializes the cache by referencing the value in `config.cache_store` and stores the outcome as `Rails.cache`. If this object responds to the `middleware` method, its middleware is inserted before `Rack::Runtime` in the middleware stack. diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index addc3a63a8..2e90e8728c 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -107,7 +107,7 @@ It can also be useful to save information to log files at runtime. Rails maintai ### What is the Logger? -Rails makes use of the `ActiveSupport::BufferedLogger` class to write log information. You can also substitute another logger such as `Log4r` if you wish. +Rails makes use of the `ActiveSupport::Logger` class to write log information. You can also substitute another logger such as `Log4r` if you wish. You can specify an alternative logger in your `environment.rb` or any environment file: diff --git a/guides/source/performance_testing.md b/guides/source/performance_testing.md index 182f7eb0fd..ee0059623c 100644 --- a/guides/source/performance_testing.md +++ b/guides/source/performance_testing.md @@ -415,7 +415,7 @@ tests will set the following configuration parameters: ```bash ActionController::Base.perform_caching = true ActiveSupport::Dependencies.mechanism = :require -Rails.logger.level = ActiveSupport::BufferedLogger::INFO +Rails.logger.level = ActiveSupport::Logger::INFO ``` As `ActionController::Base.perform_caching` is set to `true`, performance tests diff --git a/railties/lib/rails/generators/rails/app/templates/gitignore b/railties/lib/rails/generators/rails/app/templates/gitignore index 090799d5a0..52abb32479 100644 --- a/railties/lib/rails/generators/rails/app/templates/gitignore +++ b/railties/lib/rails/generators/rails/app/templates/gitignore @@ -4,14 +4,13 @@ # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' -# Ignore bundler related files +# Ignore bundler config /.bundle -/bin -# Ignore the default SQLite database +# Ignore the default SQLite database. /db/*.sqlite3 /db/*.sqlite3-journal -# Ignore all logfiles and tempfiles +# Ignore all logfiles and tempfiles. /log/*.log /tmp |