From b7d9d6e2cd5082d269dafbc0316e2107febe1451 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Fri, 15 Mar 2013 04:07:22 -0700 Subject: make new rails apps log to STDOUT --- railties/CHANGELOG.md | 4 ++++ railties/lib/rails/application/bootstrap.rb | 6 +----- .../rails/app/templates/config/application.rb | 2 ++ railties/test/application/configuration_test.rb | 21 +++++++++++++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 60a823de15..9e9d7e9009 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,5 +1,9 @@ ## Rails 4.0.0 (unreleased) ## +* New rails apps log to STDOUT by default + + *Terence Lee* + * Add support for generate scaffold password:digest * adds password_digest attribute to the migration diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb index 62d57c0cc6..2a845bca17 100644 --- a/railties/lib/rails/application/bootstrap.rb +++ b/railties/lib/rails/application/bootstrap.rb @@ -39,11 +39,7 @@ INFO f.binmode f.sync = config.autoflush_log # if true make sure every write flushes - logger = ActiveSupport::Logger.new f - logger.formatter = config.log_formatter - logger = ActiveSupport::TaggedLogging.new(logger) - logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase) - logger + logger = ActiveSupport::TaggedLogging.create(f, config.log_formatter, config.log_level) rescue StandardError logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDERR)) logger.level = ActiveSupport::Logger::WARN diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index daf399a538..2df2fa9a6a 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -32,5 +32,7 @@ module <%= app_const_base %> # Disable the asset pipeline. config.assets.enabled = false <% end -%> + + config.logger = ActiveSupport::TaggedLogging.create(STDOUT, config.log_formatter, config.log_level) end end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 7b45623f6c..40000b0ce6 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -670,5 +670,26 @@ module ApplicationTests end end end + + test "set logger to STDOUT by default" do + stdout = capture(:stdout) do + app = build_app + + controller :omg, <<-RUBY + class OmgController < ApplicationController + def index + Rails.logger.info "HI MOM" + render text: "omg" + end + end + RUBY + + require "#{app_path}/config/environment" + + get "/omg/index" + end + + assert stdout.include?("HI MOM"), "STDOUT does not include 'HI MOM', #{stdout}" + end end end -- cgit v1.2.3