Skip to content
This repository
Browse code

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

…in production so that PID and timestamp are logged. fixes #5388
commit 51aeae91ace4d0afb934e2d9a21000f2ddc4ea53 1 parent 2ad34f4
Aaron Patterson tenderlove authored
6 railties/lib/rails/application/bootstrap.rb
@@ -32,9 +32,9 @@ module Bootstrap
32 32 f.binmode
33 33 f.sync = config.autoflush_log # if true make sure every write flushes
34 34
35   - logger = ActiveSupport::TaggedLogging.new(
36   - ActiveSupport::Logger.new(f)
37   - )
  35 + logger = ::Logger.new f
  36 + logger.formatter = config.log_formatter
  37 + logger = ActiveSupport::TaggedLogging.new(logger)
38 38 logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase)
39 39 logger
40 40 rescue StandardError
3  railties/lib/rails/application/configuration.rb
@@ -8,7 +8,7 @@ class Configuration < ::Rails::Engine::Configuration
8 8 attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets, :autoflush_log,
9 9 :cache_classes, :cache_store, :consider_all_requests_local, :console,
10 10 :dependency_loading, :exceptions_app, :file_watcher, :filter_parameters,
11   - :force_ssl, :helpers_paths, :logger, :log_tags, :preload_frameworks,
  11 + :force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags, :preload_frameworks,
12 12 :railties_order, :relative_url_root, :secret_token,
13 13 :serve_static_assets, :ssl_options, :static_cache_control, :session_options,
14 14 :time_zone, :reload_classes_only_on_change, :use_schema_cache_dump
@@ -41,6 +41,7 @@ def initialize(*)
41 41 @file_watcher = ActiveSupport::FileUpdateChecker
42 42 @exceptions_app = nil
43 43 @autoflush_log = true
  44 + @log_formatter = ActiveSupport::Logger::SimpleFormatter.new
44 45 @use_schema_cache_dump = true
45 46
46 47 @assets = ActiveSupport::OrderedOptions.new
2  railties/lib/rails/commands/server.rb
@@ -71,6 +71,8 @@ def start
71 71 wrapped_app # touch the app so the logger is set up
72 72
73 73 console = ActiveSupport::Logger.new($stdout)
  74 + console.formatter = Rails.logger.formatter
  75 +
74 76 Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
75 77 end
76 78
3  railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
@@ -73,4 +73,7 @@
73 73
74 74 # Disable automatic flushing of the log to improve performance.
75 75 # config.autoflush_log = false
  76 +
  77 + # Use default logging formatter so that PID and timestamp are not suppressed
  78 + config.log_formatter = ::Logger::Formatter.new
76 79 end

0 comments on commit 51aeae9

Please sign in to comment.
Something went wrong with that request. Please try again.