Skip to content

Commit

Permalink
Merge pull request #57 from epimorphics/spike/update-logging-params
Browse files Browse the repository at this point in the history
Task: Release v2.0.0
  • Loading branch information
bogdanadrianmarc authored Dec 10, 2024
2 parents e4a9ac5 + d1eaf00 commit c3a590c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 3.0.0
NewCops: enable

Layout/LineLength:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.8
3.3.5
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog for the JSON Rails Logger gem

## 2.0.0 - 2024-12

- (Jon) Updated the gemspec for the required ruby version to 3.0.0 to ensure the
gem is up to date with the latest ruby version
- (Jon) Updated the gemspec to ensure the railties gem is locked to the 7.0 rails
version to avoid any potential issues with the gem being used
- (Jon) Updated the logging to include the `request_id` in the JSON output to
ensure the values are always logged to the system tooling.

## 1.1.1 - 2024-10

- (Jon) Updated the exposed keys to allow more flexibility in the logging
Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Specify your gem's dependencies in json_rails_logger.gemspec
gemspec

group :development, :test do
gem 'rake', '~> 13.2', '>= 13.2.1'
gem 'rubocop', '~> 1.69', '>= 1.69.1'
end
11 changes: 4 additions & 7 deletions json_rails_logger.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
spec.email = '[email protected]'
spec.homepage = 'https://github.com/epimorphics/json-rails-logger'
spec.license = 'MIT'
spec.required_ruby_version = '>= 2.6'
spec.required_ruby_version = '>= 3.0.0'

spec.metadata = {
'github_repo' => '[email protected]:epimorphics/json-rails-logger.git',
Expand All @@ -27,10 +27,7 @@ Gem::Specification.new do |spec|
end
spec.require_paths = ['lib']

spec.add_runtime_dependency 'json', '~> 2.0'
spec.add_runtime_dependency 'lograge', '~> 0.11'
spec.add_runtime_dependency 'railties', '~> 6.0'

spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rubocop', '~> 1.25.0'
spec.add_dependency 'json'
spec.add_dependency 'lograge'
spec.add_dependency 'railties', '~> 7.0'
end
6 changes: 2 additions & 4 deletions lib/json_rails_logger/json_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ def call(severity, timestamp, _progname, raw_msg) # rubocop:disable Metrics/AbcS
level: sev
}

payload.merge!(query_string.to_h)
payload.merge!(query_string.to_h) unless query_string.nil?
payload.merge!(request_id.to_h)
payload.merge!(new_msg.to_h.except!(:optional).compact)

"\n#{payload.to_json}\n" if Rails.env.development?

"#{payload.to_json}\n"
end
# rubocop:enable Metrics/MethodLength
Expand All @@ -89,7 +87,7 @@ def request_id

def query_string
query_string = Thread.current[JsonRailsLogger::QUERY_STRING]
{ query_string: query_string } if query_string
{ query_string: query_string } if query_string.present?
end

def process_message(raw_msg)
Expand Down
8 changes: 4 additions & 4 deletions lib/json_rails_logger/version.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

module JsonRailsLogger
MAJOR = 1
MINOR = 1
PATCH = 1
MAJOR = 2
MINOR = 0
PATCH = 0
SUFFIX = nil
VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}#{SUFFIX && "-#{SUFFIX}"}"
VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}#{SUFFIX && "-#{SUFFIX}"}".freeze
end

0 comments on commit c3a590c

Please sign in to comment.