Skip to content

Commit

Permalink
Merge pull request #52 from epimorphics/spike/additional-logging-keys
Browse files Browse the repository at this point in the history
Updated Logging Keys
  • Loading branch information
jonrandahl authored Jun 23, 2023
2 parents 3d77909 + 8288551 commit 709c16a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog for the JSON Rails Logger gem

## 1.0.3 - 2023-06-23

- (Jon) For continued improvements to the logs, additional keys need to be added
to parse the details
- Also includes string downcasing to improve matching of request fields

## 1.0.2 - 2023-06-21

- (Jon) Renamed parameter to reduce chance of conflict with other gems or code
Expand Down
6 changes: 3 additions & 3 deletions lib/json_rails_logger/json_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module JsonRailsLogger
class JsonFormatter < ::Logger::Formatter
## Required keys to be logged to the output
REQUIRED_KEYS = %w[
method path status duration user_agent accept request_id request_url message
method path status duration user_agent accept request_id request_url message query_string
].freeze

## Optional keys to be ignored from the output for the time being
Expand Down Expand Up @@ -101,7 +101,7 @@ def normalize_message(raw_msg)

def status_message?(msg)
msg.is_a?(String) &&
msg.match(/Status [0-9]+/)
msg.downcase.match(/status [0-9]+/)
end

def status_message(msg)
Expand All @@ -124,7 +124,7 @@ def request_type(msg)

def user_agent_message?(msg)
msg.is_a?(String) &&
msg.match(/User-Agent: .[\S\s]+Accept: .+/m)
msg.downcase.match(/user-agent: .[\S\s]+accept: .+/m)
end

def user_agent_message(msg)
Expand Down
2 changes: 1 addition & 1 deletion lib/json_rails_logger/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module JsonRailsLogger
MAJOR = 1
MINOR = 0
PATCH = 2
PATCH = 3
SUFFIX = nil
VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}#{SUFFIX && ".#{SUFFIX}"}"
end

0 comments on commit 709c16a

Please sign in to comment.