logcraft-sidekiq 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2322ef0bc6be2a50e4b4dcf0a66876b53d116a5f14de3dcdf550bbb7bd4da4ad
4
- data.tar.gz: b4369d176d52c6b1fda974f5c2251d8d96facb458a1407c3153b2e0f78b89409
3
+ metadata.gz: 0e418eca7f621e2b923267d18660dd53d1bd66a744789e52c42be26b08ef88a0
4
+ data.tar.gz: 7e4bcf27f2f0b329e1540294ac6636f229ec676c0167c06d996cf5e4cc356767
5
5
  SHA512:
6
- metadata.gz: 9e5c2dd739aab79f00820fb51cc734b358c1308bf4cb8b67716d8d13a1ef1770fb1c44a55afff8de64ed278245fd2c016327927aa3f31a8985bb979c6d399e22
7
- data.tar.gz: 920ba562c1de6d51258e0cf9345da786eaa9cbe77dd5fb7ef431d4242371da897f5f6c6fa14d4dbdc2cfce6812149e4a5d0306c1c121944c5bfe4e8a77f7807a
6
+ metadata.gz: ec5a733a392e86a7c7a903e7a1fb2ada15db050dccc1e78a8d21d46af3fc8095eae2360108444db87f4908bfd1d11c019832d3cf1876eadc61113e3856bf9921
7
+ data.tar.gz: 6acb7edb71a36a93d6d5fcd6fae09b560715839d096080f989d220af0ac6bc2ee70ef5e54bfd4e93e9aa380bbe2fedb6cb66d5074955470c0c769cf99bcfaf3c
data/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.2.0] - 2024-07-24
8
+ ### Added
9
+ - Added support for Sidekiq 7. Thanks to [@wfarr](https://github.com/wfarr) for contributing! ([#4](https://github.com/zormandi/logcraft-sidekiq/pull/4))
10
+
11
+ ### Fixed
12
+ - Eliminated deprecation warning in preparation for Sidekiq 8. Thanks to [@wfarr](https://github.com/wfarr) for contributing! ([#3](https://github.com/zormandi/logcraft-sidekiq/pull/3))
13
+
14
+ ## [1.1.0] - 2023-08-19
15
+ ### Added
16
+ - Added support for Sidekiq 7.
17
+ - Added support for request-specific context (`CurrentAttributes`).
18
+ See this [blog post](https://www.mikeperham.com/2022/07/29/sidekiq-and-request-specific-context/) for details.
19
+
7
20
  ## [1.0.0] - 2022-08-01
8
21
 
9
22
  No changes, just publishing the release candidate as a final release.
data/Gemfile CHANGED
@@ -6,5 +6,5 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  group :test do
9
- gem 'sidekiq', '~> 6.0'
9
+ gem 'sidekiq', '~> 7.0'
10
10
  end
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Gem Version](https://badge.fury.io/rb/logcraft-sidekiq.svg)](https://badge.fury.io/rb/logcraft-sidekiq)
5
5
 
6
6
  Logcraft::Sidekiq is a structured logging solution for [Sidekiq](https://github.com/mperham/sidekiq), using
7
- the [Logcraft](https://github.com/zormandi/logcraft) gem.
7
+ the [Logcraft](https://github.com/zormandi/logcraft) gem. It supports (and is tested with) Sidekiq 6 and 7.
8
8
 
9
9
  ## Installation
10
10
 
@@ -7,4 +7,5 @@ gemspec path: '..'
7
7
 
8
8
  group :test do
9
9
  gem 'sidekiq', '~> 6.0.0'
10
+ gem 'redis', '~> 4.5.0'
10
11
  end
@@ -7,4 +7,5 @@ gemspec path: '..'
7
7
 
8
8
  group :test do
9
9
  gem 'sidekiq', '~> 6.4.0'
10
+ gem 'redis', '~> 4.5.0'
10
11
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in logcraft-sidekiq.gemspec
6
+ gemspec path: '..'
7
+
8
+ group :test do
9
+ gem 'sidekiq', '~> 7.0.0'
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in logcraft-sidekiq.gemspec
6
+ gemspec path: '..'
7
+
8
+ group :test do
9
+ gem 'sidekiq', '~> 7.3.0'
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in logcraft-sidekiq.gemspec
6
+ gemspec path: '..'
7
+
8
+ group :test do
9
+ gem 'sidekiq', '~> 7.0'
10
+ end
@@ -5,7 +5,7 @@ module Logcraft
5
5
  class ErrorLogger
6
6
  include Logcraft::LogContextHelper
7
7
 
8
- def call(error, context)
8
+ def call(error, context, _config = nil)
9
9
  within_log_context(JobContext.from_job_hash(context[:job])) do
10
10
  ::Sidekiq.logger.warn error
11
11
  end
@@ -23,6 +23,7 @@ module Logcraft
23
23
  }
24
24
  info_hash[:bid] = job['bid'] if job['bid']
25
25
  info_hash[:tags] = job['tags'] if job['tags']
26
+ info_hash[:cattr] = job['cattr'] if job['cattr']
26
27
  info_hash
27
28
  end
28
29
 
@@ -5,14 +5,22 @@ module Logcraft
5
5
  class JobLogger
6
6
  include Logcraft::LogContextHelper
7
7
 
8
+ def initialize(config_or_logger = ::Sidekiq.logger)
9
+ @logger = if config_or_logger.respond_to? :logger
10
+ config_or_logger.logger
11
+ else
12
+ config_or_logger
13
+ end
14
+ end
15
+
8
16
  def call(job_hash, _queue)
9
17
  within_log_context(JobContext.from_job_hash(job_hash)) do
10
18
  begin
11
- logger.info "#{job_hash['class']} started"
19
+ @logger.info "#{job_hash['class']} started"
12
20
  benchmark { yield }
13
- logger.info message: "#{job_hash['class']} finished"
21
+ @logger.info message: "#{job_hash['class']} finished"
14
22
  rescue Exception
15
- logger.info message: "#{job_hash['class']} failed"
23
+ @logger.info message: "#{job_hash['class']} failed"
16
24
  raise
17
25
  end
18
26
  end
@@ -32,10 +40,6 @@ module Logcraft
32
40
  add_to_log_context duration: end_time - start_time,
33
41
  duration_sec: (end_time - start_time) / 1000.0
34
42
  end
35
-
36
- def logger
37
- ::Sidekiq.logger
38
- end
39
43
  end
40
44
  end
41
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Logcraft
4
4
  module Sidekiq
5
- VERSION = '1.0.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
@@ -14,7 +14,7 @@ module Logcraft
14
14
  autoload :JobLogger, 'logcraft/sidekiq/job_logger'
15
15
 
16
16
  def self.initialize
17
- ::Sidekiq.logger = Logcraft.logger 'Sidekiq'
17
+ initialize_logger
18
18
  ::Sidekiq.configure_server do |config|
19
19
  if config.respond_to? :[]=
20
20
  config[:job_logger] = JobLogger
@@ -23,11 +23,22 @@ module Logcraft
23
23
  end
24
24
  config.error_handlers.delete_if do |handler|
25
25
  (defined?(::Sidekiq::ExceptionHandler) && defined?(::Sidekiq::ExceptionHandler::Logger) && handler.is_a?(::Sidekiq::ExceptionHandler::Logger)) ||
26
- (handler.is_a?(Method) && handler.receiver.name == 'Sidekiq' && handler.name == :default_error_handler)
26
+ (handler.is_a?(Method) && handler.receiver.name == 'Sidekiq' && handler.name == :default_error_handler) ||
27
+ (defined?(::Sidekiq::Config) && defined?(::Sidekiq::Config::ERROR_HANDLER) && (handler == ::Sidekiq::Config::ERROR_HANDLER))
27
28
  end
28
29
  config.error_handlers << ErrorLogger.new
29
30
  config.death_handlers << DeathLogger.new
30
31
  end
31
32
  end
33
+
34
+ def self.initialize_logger
35
+ case ::Sidekiq::VERSION.chr
36
+ when '7'
37
+ ::Sidekiq.configure_client { |config| config.logger = Logcraft.logger 'Sidekiq' }
38
+ ::Sidekiq.configure_server { |config| config.logger = Logcraft.logger 'Sidekiq' }
39
+ when '6'
40
+ ::Sidekiq.logger = Logcraft.logger 'Sidekiq'
41
+ end
42
+ end
32
43
  end
33
44
  end
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
 
31
31
  spec.add_dependency "logcraft"
32
- spec.add_dependency "sidekiq", "~> 6.0"
32
+ spec.add_dependency "sidekiq", ">= 6.0", "< 8.0"
33
33
 
34
34
  spec.add_development_dependency "bundler", "~> 2.0"
35
35
  spec.add_development_dependency "rake", ">= 12.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logcraft-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoltan Ormandi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-01 00:00:00.000000000 Z
11
+ date: 2024-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logcraft
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: sidekiq
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '6.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '8.0'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '6.0'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '8.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +86,7 @@ dependencies:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
88
  version: '3.0'
83
- description:
89
+ description:
84
90
  email:
85
91
  - zoltan.ormandi@gmail.com
86
92
  executables: []
@@ -97,6 +103,9 @@ files:
97
103
  - gemfiles/sidekiq_6.0.gemfile
98
104
  - gemfiles/sidekiq_6.4.gemfile
99
105
  - gemfiles/sidekiq_6.5.gemfile
106
+ - gemfiles/sidekiq_7.0.gemfile
107
+ - gemfiles/sidekiq_7.3.gemfile
108
+ - gemfiles/sidekiq_7.latest.gemfile
100
109
  - lib/logcraft/sidekiq.rb
101
110
  - lib/logcraft/sidekiq/death_logger.rb
102
111
  - lib/logcraft/sidekiq/error_logger.rb
@@ -113,7 +122,7 @@ metadata:
113
122
  homepage_uri: https://github.com/zormandi/logcraft-sidekiq
114
123
  source_code_uri: https://github.com/zormandi/logcraft-sidekiq
115
124
  changelog_uri: https://github.com/zormandi/logcraft-sidekiq/blob/main/CHANGELOG.md
116
- post_install_message:
125
+ post_install_message:
117
126
  rdoc_options: []
118
127
  require_paths:
119
128
  - lib
@@ -128,8 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
137
  - !ruby/object:Gem::Version
129
138
  version: '0'
130
139
  requirements: []
131
- rubygems_version: 3.1.6
132
- signing_key:
140
+ rubygems_version: 3.4.10
141
+ signing_key:
133
142
  specification_version: 4
134
143
  summary: A structured logging solution for Sidekiq, using Logcraft.
135
144
  test_files: []