aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands/server.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/commands/server.rb')
-rw-r--r--railties/lib/rails/commands/server.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb
index 851a21c51d..115499db05 100644
--- a/railties/lib/rails/commands/server.rb
+++ b/railties/lib/rails/commands/server.rb
@@ -46,7 +46,7 @@ module Rails
trap(:INT) { exit }
puts "=> Ctrl-C to shutdown server" unless options[:daemonize]
- Rails::Subscriber.tail_log = true unless options[:daemonize]
+ initialize_log_tailer! unless options[:daemonize]
super
ensure
puts 'Exiting' unless options[:daemonize]
@@ -58,6 +58,10 @@ module Rails
Hash.new(middlewares)
end
+ def log_path
+ "log/#{options[:environment]}.log"
+ end
+
def default_options
super.merge({
:Port => 3000,
@@ -67,5 +71,14 @@ module Rails
:pid => "tmp/pids/server.pid"
})
end
+
+ protected
+
+ # LogTailer should not be used as a middleware since the logging happens
+ # async in a request and the middleware calls are sync. So we send it
+ # to subscriber which will be responsible for calling tail! in the log tailer.
+ def initialize_log_tailer!
+ Rails::Subscriber.log_tailer = Rails::Rack::LogTailer.new(nil, log_path)
+ end
end
end