Permalink
Browse files

Merge pull request #11060 from schneems/schneems/multi-stdout-logging…

…-master

Only output Server logs in Development
  • Loading branch information...
2 parents 7dcde9f + 5f98bb4 commit c21941b1c71b9254103929117670e7cbb53aa243 @guilleiguaran guilleiguaran committed Sep 23, 2013
Showing with 18 additions and 2 deletions.
  1. +5 −0 railties/CHANGELOG.md
  2. +3 −2 railties/lib/rails/commands/server.rb
  3. +10 −0 railties/test/commands/server_test.rb
View
5 railties/CHANGELOG.md
@@ -1,3 +1,8 @@
+* `rails server` will only extend the logger to output to STDOUT
+ in development environment.
+
+ *Richard Schneeman*
+
* Don't require passing path to app before options in `rails new`
and `rails plugin new`
View
5 railties/lib/rails/commands/server.rb
@@ -32,7 +32,8 @@ def parse!(args)
opt_parser.parse! args
- options[:server] = args.shift
+ options[:log_stdout] = options[:daemonize].blank? && options[:environment] == "development"
+ options[:server] = args.shift
options
end
end
@@ -74,7 +75,7 @@ def start
FileUtils.mkdir_p(File.join(Rails.root, 'tmp', dir_to_make))
end
- unless options[:daemonize]
+ if options[:log_stdout]
wrapped_app # touch the app so the logger is set up
console = ActiveSupport::Logger.new($stdout)
View
10 railties/test/commands/server_test.rb
@@ -39,4 +39,14 @@ def test_environment_with_rack_env
assert_equal 'production', server.options[:environment]
end
end
+
+ def test_log_stdout
+ args = ["-e", "development"]
+ options = Rails::Server::Options.new.parse!(args)
+ assert_equal true, options[:log_stdout]
+
+ args = ["-e", "production"]
+ options = Rails::Server::Options.new.parse!(args)
+ assert_equal false, options[:log_stdout]
+ end
end

0 comments on commit c21941b

Please sign in to comment.