Skip to content

Commit

Permalink
Merge pull request #5270 from sul-dlss/logging-outside-rack
Browse files Browse the repository at this point in the history
Add log formatter to application config
  • Loading branch information
justinlittman authored Feb 24, 2025
2 parents b3b7058 + d402d8f commit 26c0115
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 5 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ class Application < Rails::Application
Cocina::Models::Mapping::Purl.base_url = Settings.release.purl_base_url
end

# Add timestamps to all loggers (both Rack-based ones and e.g. Sidekiq's)
config.log_formatter = proc do |severity, datetime, _progname, msg|
"[#{datetime.to_fs(:iso8601)}] [#{severity}] #{msg}\n"
end

# Only loads a smaller set of middleware suitable for API only apps.
# Middleware like session, flash, cookies can be added back manually.
# Skip views, helpers and assets when generating a new resource.
Expand Down
5 changes: 1 addition & 4 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@
end

# Prepend all log lines with the following tags.
config.log_tags = [
->(_request) { Time.now.iso8601 },
:request_id
]
config.log_tags = [:request_id]

# "info" includes generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
Expand Down

0 comments on commit 26c0115

Please sign in to comment.