Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make logging to stdout work again with implicit development env #12514

Merged
merged 1 commit into from
Oct 13, 2013
Merged

Make logging to stdout work again with implicit development env #12514

merged 1 commit into from
Oct 13, 2013

Conversation

schuetzm
Copy link
Contributor

PR #11060 disabled logging of rails server to stdout in non-development environments. It did so by checking whether -e development was passed explicitly. However, development environment can also be set using the RAILS_ENV or RACK_ENV variables or by not specifying an environment at all. In these cases, logging to stdout was suppressed, too. This means that simply running rails server would no longer output anything. This PR fixes the problem and adds further tests.

@@ -32,7 +32,8 @@ def parse!(args)

opt_parser.parse! args

options[:log_stdout] = options[:daemonize].blank? && options[:environment] == "development"
options[:log_stdout] = options[:daemonize].blank? &&
(options[:environment] || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development") == "development"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not we use Rails.env?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that, but it relies on ENV['RAILS_ENV'] for the check, which gets only assigned by set_environment when a Rails::Server instance is initialized. I don't see a way to pass command line args (-e development) to Rails::Server.new; apparently this is only possible by starting the server. This would then be very difficult to write a test for.

Maybe you see a better solution which is more DRY?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options[:environment] || Rails.env || "development"

?

@schuetzm
Copy link
Contributor Author

@rafaelfranca Got it now, thanks! (Though it required some dirty fighting against the fact that rake test sets RAILS_ENV to test and Rails.env is cached...)

rafaelfranca added a commit that referenced this pull request Oct 13, 2013
…development-env

Make logging to stdout work again with implicit `development` env
@rafaelfranca rafaelfranca merged commit b205ae8 into rails:master Oct 13, 2013
@schuetzm schuetzm deleted the stdout-logging-with-implicit-development-env branch October 14, 2013 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants