From 92b077cf55a40d30f8bc41e5a62c730a34f2150e Mon Sep 17 00:00:00 2001 From: Peter Hankiewicz Date: Wed, 14 Sep 2022 13:02:00 +0200 Subject: [PATCH] Add request information to 404s log messages --- CHANGELOG.md | 4 ++++ app/controllers/application_controller.rb | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd9341ec..222bc96f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). It uses [CalVer](https://calver.org/) as of May 2019. +## [22.09c](https://github.com/berkmancenter/lumendatabase/releases/tag/2022.09c) - 2022-09-14 +### Added +* Added `request` information to `404s log messages`. + ## [22.09b](https://github.com/berkmancenter/lumendatabase/releases/tag/2022.09b) - 2022-09-13 ### Fixed * Set the proper type for `jsonb` fields to correctly render in the `admin`. diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1461170a..2c8a007c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -51,7 +51,18 @@ def routing_error def resource_not_found(exception = false) logger404s = Logger.new("#{Rails.root}/log/#{Rails.env}_404s.log") - logger404s.error(exception) if exception + if exception + logger404s.error( + format( + 'Exception %s "%s" for %s at %s', + request.raw_request_method, + request.filtered_path, + request.remote_ip, + Time.now.to_default_s + ) + ) + logger404s.error(exception) + end set_default_format