Skip to content

Commit

Permalink
allow people to specify custom formatters, use the default formatter …
Browse files Browse the repository at this point in the history
…in production so that PID and timestamp are logged. fixes #5388
  • Loading branch information
tenderlove committed Mar 12, 2012
1 parent 2ad34f4 commit 51aeae9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions railties/lib/rails/application/bootstrap.rb
Expand Up @@ -32,9 +32,9 @@ module Bootstrap
f.binmode f.binmode
f.sync = config.autoflush_log # if true make sure every write flushes f.sync = config.autoflush_log # if true make sure every write flushes


logger = ActiveSupport::TaggedLogging.new( logger = ::Logger.new f
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.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
logger logger
rescue StandardError rescue StandardError
Expand Down
3 changes: 2 additions & 1 deletion railties/lib/rails/application/configuration.rb
Expand Up @@ -8,7 +8,7 @@ class Configuration < ::Rails::Engine::Configuration
attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets, :autoflush_log, attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets, :autoflush_log,
:cache_classes, :cache_store, :consider_all_requests_local, :console, :cache_classes, :cache_store, :consider_all_requests_local, :console,
:dependency_loading, :exceptions_app, :file_watcher, :filter_parameters, :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, :railties_order, :relative_url_root, :secret_token,
:serve_static_assets, :ssl_options, :static_cache_control, :session_options, :serve_static_assets, :ssl_options, :static_cache_control, :session_options,
:time_zone, :reload_classes_only_on_change, :use_schema_cache_dump :time_zone, :reload_classes_only_on_change, :use_schema_cache_dump
Expand Down Expand Up @@ -41,6 +41,7 @@ def initialize(*)
@file_watcher = ActiveSupport::FileUpdateChecker @file_watcher = ActiveSupport::FileUpdateChecker
@exceptions_app = nil @exceptions_app = nil
@autoflush_log = true @autoflush_log = true
@log_formatter = ActiveSupport::Logger::SimpleFormatter.new
@use_schema_cache_dump = true @use_schema_cache_dump = true


@assets = ActiveSupport::OrderedOptions.new @assets = ActiveSupport::OrderedOptions.new
Expand Down
2 changes: 2 additions & 0 deletions railties/lib/rails/commands/server.rb
Expand Up @@ -71,6 +71,8 @@ def start
wrapped_app # touch the app so the logger is set up wrapped_app # touch the app so the logger is set up


console = ActiveSupport::Logger.new($stdout) console = ActiveSupport::Logger.new($stdout)
console.formatter = Rails.logger.formatter

Rails.logger.extend(ActiveSupport::Logger.broadcast(console)) Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
end end


Expand Down
Expand Up @@ -73,4 +73,7 @@


# Disable automatic flushing of the log to improve performance. # Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false # config.autoflush_log = false

# Use default logging formatter so that PID and timestamp are not suppressed
config.log_formatter = ::Logger::Formatter.new
end end

0 comments on commit 51aeae9

Please sign in to comment.