Permalink
Browse files

allow people to specify custom formatters, use the default formatter …

…in production so that PID and timestamp are logged. fixes #5388
  • Loading branch information...
1 parent 2ad34f4 commit 51aeae91ace4d0afb934e2d9a21000f2ddc4ea53 @tenderlove tenderlove committed Mar 12, 2012
View
6 railties/lib/rails/application/bootstrap.rb
@@ -32,9 +32,9 @@ module Bootstrap
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
View
3 railties/lib/rails/application/configuration.rb
@@ -8,7 +8,7 @@ class Configuration < ::Rails::Engine::Configuration
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 @@ def initialize(*)
@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
View
2 railties/lib/rails/commands/server.rb
@@ -71,6 +71,8 @@ def start
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
View
3 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

0 comments on commit 51aeae9

Please sign in to comment.