aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-03-12 14:25:25 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-03-12 14:25:41 -0700
commit51aeae91ace4d0afb934e2d9a21000f2ddc4ea53 (patch)
treee5438cd412226eaccebb17397a56a190867246d7
parent2ad34f46a1c4b8c59f37c2846ed0fcf3b4401e3a (diff)
downloadrails-51aeae91ace4d0afb934e2d9a21000f2ddc4ea53.tar.gz
rails-51aeae91ace4d0afb934e2d9a21000f2ddc4ea53.tar.bz2
rails-51aeae91ace4d0afb934e2d9a21000f2ddc4ea53.zip
allow people to specify custom formatters, use the default formatter in production so that PID and timestamp are logged. fixes #5388
-rw-r--r--railties/lib/rails/application/bootstrap.rb6
-rw-r--r--railties/lib/rails/application/configuration.rb3
-rw-r--r--railties/lib/rails/commands/server.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt3
4 files changed, 10 insertions, 4 deletions
diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb
index 93a0fba10b..4ee77f7726 100644
--- a/railties/lib/rails/application/bootstrap.rb
+++ b/railties/lib/rails/application/bootstrap.rb
@@ -32,9 +32,9 @@ module Rails
f.binmode
f.sync = config.autoflush_log # if true make sure every write flushes
- logger = ActiveSupport::TaggedLogging.new(
- ActiveSupport::Logger.new(f)
- )
+ logger = ::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
rescue StandardError
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 0f5fc2b7bc..1cfcd30c5b 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -8,7 +8,7 @@ module Rails
attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets, :autoflush_log,
:cache_classes, :cache_store, :consider_all_requests_local, :console,
:dependency_loading, :exceptions_app, :file_watcher, :filter_parameters,
- :force_ssl, :helpers_paths, :logger, :log_tags, :preload_frameworks,
+ :force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags, :preload_frameworks,
:railties_order, :relative_url_root, :secret_token,
:serve_static_assets, :ssl_options, :static_cache_control, :session_options,
:time_zone, :reload_classes_only_on_change, :use_schema_cache_dump
@@ -41,6 +41,7 @@ module Rails
@file_watcher = ActiveSupport::FileUpdateChecker
@exceptions_app = nil
@autoflush_log = true
+ @log_formatter = ActiveSupport::Logger::SimpleFormatter.new
@use_schema_cache_dump = true
@assets = ActiveSupport::OrderedOptions.new
diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb
index 0b757cbe28..a608693ca4 100644
--- a/railties/lib/rails/commands/server.rb
+++ b/railties/lib/rails/commands/server.rb
@@ -71,6 +71,8 @@ module Rails
wrapped_app # touch the app so the logger is set up
console = ActiveSupport::Logger.new($stdout)
+ console.formatter = Rails.logger.formatter
+
Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
end
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
index 7041550fd0..d0d9083c37 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
@@ -73,4 +73,7 @@
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
+
+ # Use default logging formatter so that PID and timestamp are not suppressed
+ config.log_formatter = ::Logger::Formatter.new
end