Skip to content
This repository
Browse code

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

…-master

Only output Server logs in Development
  • Loading branch information...
commit c21941b1c71b9254103929117670e7cbb53aa243 2 parents 7dcde9f + 5f98bb4
Guillermo Iguaran guilleiguaran authored
5 railties/CHANGELOG.md
Source Rendered
... ... @@ -1,3 +1,8 @@
  1 +* `rails server` will only extend the logger to output to STDOUT
  2 + in development environment.
  3 +
  4 + *Richard Schneeman*
  5 +
1 6 * Don't require passing path to app before options in `rails new`
2 7 and `rails plugin new`
3 8
5 railties/lib/rails/commands/server.rb
@@ -32,7 +32,8 @@ def parse!(args)
32 32
33 33 opt_parser.parse! args
34 34
35   - options[:server] = args.shift
  35 + options[:log_stdout] = options[:daemonize].blank? && options[:environment] == "development"
  36 + options[:server] = args.shift
36 37 options
37 38 end
38 39 end
@@ -74,7 +75,7 @@ def start
74 75 FileUtils.mkdir_p(File.join(Rails.root, 'tmp', dir_to_make))
75 76 end
76 77
77   - unless options[:daemonize]
  78 + if options[:log_stdout]
78 79 wrapped_app # touch the app so the logger is set up
79 80
80 81 console = ActiveSupport::Logger.new($stdout)
10 railties/test/commands/server_test.rb
@@ -39,4 +39,14 @@ def test_environment_with_rack_env
39 39 assert_equal 'production', server.options[:environment]
40 40 end
41 41 end
  42 +
  43 + def test_log_stdout
  44 + args = ["-e", "development"]
  45 + options = Rails::Server::Options.new.parse!(args)
  46 + assert_equal true, options[:log_stdout]
  47 +
  48 + args = ["-e", "production"]
  49 + options = Rails::Server::Options.new.parse!(args)
  50 + assert_equal false, options[:log_stdout]
  51 + end
42 52 end

0 comments on commit c21941b

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