Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- "3.1"
- "3.2"
- "3.3"
- "3.4"

# JRuby
- jruby-9.3
Expand All @@ -31,7 +32,9 @@ jobs:

gemfile:
- Gemfile
- gemfiles/rails_edge.gemfile # 7.2.0.alpha
- gemfiles/rails_edge.gemfile # 8.1
- gemfiles/rails_8.0.gemfile
- gemfiles/rails_7.2.gemfile
- gemfiles/rails_7.1.gemfile
- gemfiles/rails_7.0.gemfile
- gemfiles/rails_6.1.gemfile
Expand All @@ -51,21 +54,51 @@ jobs:
# NOTE(ivy): Rails 7 requires Ruby version >= 2.7
- ruby: jruby-9.3
gemfile: gemfiles/rails_edge.gemfile
- ruby: jruby-9.3
gemfile: gemfiles/rails_7.2.gemfile
- ruby: jruby-9.3
gemfile: gemfiles/rails_7.1.gemfile
- ruby: jruby-9.3
gemfile: gemfiles/rails_7.0.gemfile
- ruby: jruby-9.2
gemfile: gemfiles/rails_edge.gemfile
- ruby: jruby-9.2
gemfile: gemfiles/rails_7.2.gemfile
- ruby: jruby-9.2
gemfile: gemfiles/rails_7.1.gemfile
- ruby: jruby-9.2
gemfile: gemfiles/rails_7.0.gemfile
# NOTE: Rails edge requires Ruby version >= 3.1
# NOTE: Rails 7.2 requires Ruby version >= 3.1
- ruby: "2.7"
gemfile: gemfiles/rails_7.2.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_7.2.gemfile
# NOTE: Rails 8.0 edge requires Ruby version >= 3.2
- ruby: "2.7"
gemfile: gemfiles/rails_8.0.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_8.0.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_8.0.gemfile
- ruby: jruby-9.3
gemfile: gemfiles/rails_8.0.gemfile
- ruby: jruby-9.4
gemfile: gemfiles/rails_8.0.gemfile
- ruby: truffleruby-23.0
gemfile: gemfiles/rails_8.0.gemfile
# NOTE: Rails edge requires Ruby version >= 3.2
- ruby: "2.7"
gemfile: gemfiles/rails_edge.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_edge.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_edge.gemfile
- ruby: jruby-9.3
gemfile: gemfiles/rails_edge.gemfile
- ruby: jruby-9.4
gemfile: gemfiles/rails_edge.gemfile
- ruby: truffleruby-23.0
gemfile: gemfiles/rails_edge.gemfile


env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
Gemfile.lock
coverage
gemfiles/*.lock
gemfiles/vendor
pkg/*
vendor/bundle
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ group :test do
gem 'jrjackson', '~> 0.2.9', platforms: :jruby
gem 'lines'
gem 'thread_safe'

# Since Ruby-3.4 vendored stdlib logger warns that it will be removed
# Since Ruby-3.5 logger is extracted into a standalone gem
gem 'logger'
end
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ default, instead it assumes you use a proper log formatter instead.
Lograge is actively tested against current and officially supported Ruby and
Rails releases. That said, Lograge _should_ work with older releases.

- [Rails](https://endoflife.date/rails): Edge, 7.1, 7.0, 6.1, 6.0, 5.2
- [Rails](https://endoflife.date/rails): Edge, 8.0, 7.2, 7.1, 7.0, 6.1, 6.0, 5.2
- Rubies:
- [MRI](https://endoflife.date/ruby): HEAD, 3.3, 3.2 3.1, 3.0, 2.7, 2.6
- [MRI](https://endoflife.date/ruby): HEAD, 3.4, 3.3, 3.2 3.1, 3.0, 2.7, 2.6
- JRuby: HEAD, 9.2, 9.1
- TruffleRuby: HEAD, 21.3

Expand Down
19 changes: 19 additions & 0 deletions gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in lograge.gemspec
gemspec path: '..'

group :test do
gem 'actionpack', '~> 7.2.0'
gem 'activerecord', '~> 7.2.0'
# logstash does not release any gems on rubygems, but they have two gemspecs within their repo.
# Using the tag is an attempt of having a stable version to test against where we can ensure that
# we test against the correct code.
gem 'logstash-event', git: 'https://github.com/elastic/logstash', tag: 'v1.5.4'
# logstash 1.5.4 is only supported with jrjackson up to 0.2.9
gem 'jrjackson', '~> 0.2.9', platforms: :jruby
gem 'lines'
gem 'thread_safe'
end
19 changes: 19 additions & 0 deletions gemfiles/rails_8.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in lograge.gemspec
gemspec path: '..'

group :test do
gem 'actionpack', '~> 8.0.0'
gem 'activerecord', '~> 8.0.0'
# logstash does not release any gems on rubygems, but they have two gemspecs within their repo.
# Using the tag is an attempt of having a stable version to test against where we can ensure that
# we test against the correct code.
gem 'logstash-event', git: 'https://github.com/elastic/logstash', tag: 'v1.5.4'
# logstash 1.5.4 is only supported with jrjackson up to 0.2.9
gem 'jrjackson', '~> 0.2.9', platforms: :jruby
gem 'lines'
gem 'thread_safe'
end
1 change: 1 addition & 0 deletions lib/lograge.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'logger'
require 'lograge/version'
require 'lograge/formatters/helpers/method_and_path'
require 'lograge/formatters/cee'
Expand Down
8 changes: 4 additions & 4 deletions lograge.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rubocop', '~> 1.23'
s.add_development_dependency 'simplecov', '~> 0.21'

s.add_runtime_dependency 'actionpack', '>= 4'
s.add_runtime_dependency 'activesupport', '>= 4'
s.add_runtime_dependency 'railties', '>= 4'
s.add_runtime_dependency 'request_store', '~> 1.0'
s.add_dependency 'actionpack', '>= 4'
s.add_dependency 'activesupport', '>= 4'
s.add_dependency 'railties', '>= 4'
s.add_dependency 'request_store', '~> 1.0'
end
6 changes: 3 additions & 3 deletions spec/log_subscribers/action_cable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@

context 'with custom_options configured for cee output' do
before do
Lograge.formatter = ->(data) { "My test: #{data}" }
Lograge.formatter = ->(data) { "My test: #{data.to_json}" }
end

it 'combines the hash properly for the output' do
Lograge.custom_options = { data: 'value' }
subscriber.perform_action(event)
expect(log_output.string).to match(/^My test: {.*:data=>"value"/)
expect(log_output.string).to match(/^My test: {.*"data"\s*:\s*"value"/)
end

it 'combines the output of a lambda properly' do
Lograge.custom_options = ->(_event) { { data: 'value' } }

subscriber.perform_action(event)
expect(log_output.string).to match(/^My test: {.*:data=>"value"/)
expect(log_output.string).to match(/^My test: {.*"data"\s*:\s*"value"/)
end

it 'works when the method returns nil' do
Expand Down
6 changes: 3 additions & 3 deletions spec/log_subscribers/action_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@

context 'with custom_options configured for cee output' do
before do
Lograge.formatter = ->(data) { "My test: #{data}" }
Lograge.formatter = ->(data) { "My test: #{data.to_json}" }
end

it 'combines the hash properly for the output' do
Lograge.custom_options = { data: 'value' }
subscriber.process_action(event)
expect(log_output.string).to match(/^My test: {.*:data=>"value"/)
expect(log_output.string).to match(/^My test: {.*"data"\s*:\s*"value"/)
end

it 'combines the output of a lambda properly' do
Lograge.custom_options = ->(_event) { { data: 'value' } }

subscriber.process_action(event)
expect(log_output.string).to match(/^My test: {.*:data=>"value"/)
expect(log_output.string).to match(/^My test: {.*"data"\s*:\s*"value"/)
end

it 'works when the method returns nil' do
Expand Down
Loading