Skip to content

Commit

Permalink
Add named log tag for environment
Browse files Browse the repository at this point in the history
This allows the various deployment environments to be distinguished in
the logs, since the `ENVIRONMENT` variable is consistent across both
development and production.

`config.log_tags` is a Ruby built-in which can be overridden as part of
Semantic Logger (see
https://rocketjob.github.io/semantic_logger/rails.html#named-tags) to
add additional parameters to all requests.

ENVIRONMENT_NAME is now also set to `local` in `.env.development`, so
developers working locally will have the variable set by default.
  • Loading branch information
jacksonj04 committed Jan 22, 2020
1 parent 6871f23 commit 1d57789
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ DFE_SIGN_IN_API_CLIENT_ID=teacherpayments
DFE_SIGN_IN_API_ENDPOINT=https://pp-api.signin.education.gov.uk

ADMIN_ALLOWED_IPS=::1,127.0.0.1
ENVIRONMENT_NAME=local
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ RUN if [ ${RAILS_ENV} = "production" ]; then \
DFE_SIGN_IN_API_SECRET= \
DFE_SIGN_IN_API_ENDPOINT= \
ADMIN_ALLOWED_IPS= \
ENVIRONMENT_NAME= \
bundle exec rake assets:precompile; \
fi

Expand Down
6 changes: 6 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,11 @@ class Application < Rails::Application
config.action_view.form_with_generates_remote_forms = false

config.guidance_url = "https://www.gov.uk/government/publications/additional-payments-for-teaching-eligibility-and-payment-details"

# Additional information which is passed in the logs for each request
# See https://rocketjob.github.io/semantic_logger/rails.html#named-tags
config.log_tags = {
environment: ENV.fetch("ENVIRONMENT_NAME", "unspecified"),
}
end
end

0 comments on commit 1d57789

Please sign in to comment.