Optionally log to stdout (#6230)

This commit is contained in:
rhymes 2020-02-21 19:56:39 +01:00 committed by GitHub
parent d13cbbb3c1
commit 9153f61ef8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View file

@ -24,10 +24,13 @@ default: &default
checkout_timeout: 2
variables:
statement_timeout: <%= ENV['STATEMENT_TIMEOUT'] || 2500 %>
development:
<<: *default
url: <%= ENV.fetch('DATABASE_URL', '') %>
database: PracticalDeveloper_development
variables:
statement_timeout: <%= ENV['STATEMENT_TIMEOUT'] || 10_000 %>
# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.

View file

@ -96,6 +96,12 @@ Rails.application.configure do
# Debug is the default log_level, but can be changed per environment.
config.log_level = :debug
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
config.after_initialize do
# See <https://github.com/flyerhzm/bullet#configuration> for other Bullet config options
Bullet.enable = true
@ -108,8 +114,7 @@ Rails.application.configure do
# acts-as-taggable-on has super weird eager loading problems: <https://github.com/mbleigh/acts-as-taggable-on/issues/91>
Bullet.add_whitelist(type: :n_plus_one_query, class_name: "ActsAsTaggableOn::Tagging", association: :tag)
DATA_UPDATE_CHECK_COMMANDS = %w[c console s server].freeze
if DATA_UPDATE_CHECK_COMMANDS.include?(ENV["COMMAND"])
if %w[c console runner s server].include?(ENV["COMMAND"])
script_ids = DataUpdateScript.load_script_ids
scripts_to_run = DataUpdateScript.where(id: script_ids).select(&:enqueued?)
if scripts_to_run.any?

View file

@ -30,3 +30,15 @@ sudo -u postgres createdb ec2-user
The first command creates the user **ec2-user** and the second one creates the
database for this user because every user needs its database. Even if the first
command fails, run the second command to create the missing database.
## How do I enable logging to standard output in development?
By default Rails logs to `log.development.log`.
If, instead, you wish to log to `STDOUT` you can add the variable:
```yaml
RAILS_LOG_TO_STDOUT: true
```
to your own `config/application.yml` file.