logcraft-sidekiq 0.99.0.rc → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/Gemfile +1 -1
- data/README.md +2 -1
- data/gemfiles/sidekiq_6.0.gemfile +1 -0
- data/gemfiles/sidekiq_6.4.gemfile +1 -0
- data/gemfiles/sidekiq_7.0.gemfile +10 -0
- data/gemfiles/sidekiq_7.latest.gemfile +10 -0
- data/lib/logcraft/sidekiq/job_context.rb +1 -0
- data/lib/logcraft/sidekiq/job_logger.rb +7 -7
- data/lib/logcraft/sidekiq/version.rb +1 -1
- data/lib/logcraft/sidekiq.rb +13 -2
- metadata +15 -8
- data/logcraft-sidekiq.gemspec +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28452045ea7393df36c7954b72551cce39009acd50519f57e8a2987f6f492d8e
|
4
|
+
data.tar.gz: 5a9a2e6fd7f3b260bfa2407a546ae10d6bb37924982b7631da5e66be0faea7a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1c1352ba7f9e634c440cfa31b5950da0842d2b3cf3f5e0e2a906fca85ffb5c92c280bbdfc70d9e59b6aa28fe337c2bbace7e30a5a37e34e1ffeea3a443a3046
|
7
|
+
data.tar.gz: 072b697fa207b85bb91e0c2af585a4e6a1f85310147e314842143ef225688f665d16d60f115b22d3fcaddcb86c17e52323ccac6d39d629cc584abca3a40056bd
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,15 @@ 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
|
-
## [
|
7
|
+
## [1.1.0] - 2023-08-19
|
8
|
+
### Added
|
9
|
+
- Added support for Sidekiq 7.
|
10
|
+
- Added support for request-specific context (`CurrentAttributes`).
|
11
|
+
See this [blog post](https://www.mikeperham.com/2022/07/29/sidekiq-and-request-specific-context/) for details.
|
12
|
+
|
13
|
+
## [1.0.0] - 2022-08-01
|
14
|
+
|
15
|
+
No changes, just publishing the release candidate as a final release.
|
8
16
|
|
9
17
|
## [0.99.0.rc] - 2022-07-18
|
10
18
|
### Added
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Logcraft::Sidekiq
|
2
2
|
|
3
3
|
[![Build Status](https://github.com/zormandi/logcraft-sidekiq/actions/workflows/main.yml/badge.svg)](https://github.com/zormandi/logcraft-sidekiq/actions/workflows/main.yml)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/logcraft-sidekiq.svg)](https://badge.fury.io/rb/logcraft-sidekiq)
|
4
5
|
|
5
6
|
Logcraft::Sidekiq is a structured logging solution for [Sidekiq](https://github.com/mperham/sidekiq), using
|
6
|
-
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.
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
@@ -5,14 +5,18 @@ module Logcraft
|
|
5
5
|
class JobLogger
|
6
6
|
include Logcraft::LogContextHelper
|
7
7
|
|
8
|
+
def initialize(logger = ::Sidekiq.logger)
|
9
|
+
@logger = logger
|
10
|
+
end
|
11
|
+
|
8
12
|
def call(job_hash, _queue)
|
9
13
|
within_log_context(JobContext.from_job_hash(job_hash)) do
|
10
14
|
begin
|
11
|
-
logger.info "#{job_hash['class']} started"
|
15
|
+
@logger.info "#{job_hash['class']} started"
|
12
16
|
benchmark { yield }
|
13
|
-
logger.info message: "#{job_hash['class']} finished"
|
17
|
+
@logger.info message: "#{job_hash['class']} finished"
|
14
18
|
rescue Exception
|
15
|
-
logger.info message: "#{job_hash['class']} failed"
|
19
|
+
@logger.info message: "#{job_hash['class']} failed"
|
16
20
|
raise
|
17
21
|
end
|
18
22
|
end
|
@@ -32,10 +36,6 @@ module Logcraft
|
|
32
36
|
add_to_log_context duration: end_time - start_time,
|
33
37
|
duration_sec: (end_time - start_time) / 1000.0
|
34
38
|
end
|
35
|
-
|
36
|
-
def logger
|
37
|
-
::Sidekiq.logger
|
38
|
-
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
data/lib/logcraft/sidekiq.rb
CHANGED
@@ -14,7 +14,7 @@ module Logcraft
|
|
14
14
|
autoload :JobLogger, 'logcraft/sidekiq/job_logger'
|
15
15
|
|
16
16
|
def self.initialize
|
17
|
-
|
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
|
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:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zoltan Ormandi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-19 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
|
@@ -97,6 +103,8 @@ 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.latest.gemfile
|
100
108
|
- lib/logcraft/sidekiq.rb
|
101
109
|
- lib/logcraft/sidekiq/death_logger.rb
|
102
110
|
- lib/logcraft/sidekiq/error_logger.rb
|
@@ -104,7 +112,6 @@ files:
|
|
104
112
|
- lib/logcraft/sidekiq/job_logger.rb
|
105
113
|
- lib/logcraft/sidekiq/railtie.rb
|
106
114
|
- lib/logcraft/sidekiq/version.rb
|
107
|
-
- logcraft-sidekiq.gemspec
|
108
115
|
- sig/logcraft/sidekiq.rbs
|
109
116
|
homepage: https://github.com/zormandi/logcraft-sidekiq
|
110
117
|
licenses:
|
@@ -124,11 +131,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
131
|
version: 2.6.0
|
125
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
133
|
requirements:
|
127
|
-
- - "
|
134
|
+
- - ">="
|
128
135
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
136
|
+
version: '0'
|
130
137
|
requirements: []
|
131
|
-
rubygems_version: 3.1
|
138
|
+
rubygems_version: 3.0.3.1
|
132
139
|
signing_key:
|
133
140
|
specification_version: 4
|
134
141
|
summary: A structured logging solution for Sidekiq, using Logcraft.
|
data/logcraft-sidekiq.gemspec
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/logcraft/sidekiq/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "logcraft-sidekiq"
|
7
|
-
spec.version = Logcraft::Sidekiq::VERSION
|
8
|
-
spec.authors = ["Zoltan Ormandi"]
|
9
|
-
spec.email = ["zoltan.ormandi@gmail.com"]
|
10
|
-
|
11
|
-
spec.summary = "A structured logging solution for Sidekiq, using Logcraft."
|
12
|
-
spec.homepage = "https://github.com/zormandi/logcraft-sidekiq"
|
13
|
-
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = ">= 2.6.0"
|
15
|
-
|
16
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
-
spec.metadata["source_code_uri"] = "https://github.com/zormandi/logcraft-sidekiq"
|
18
|
-
spec.metadata["changelog_uri"] = "https://github.com/zormandi/logcraft-sidekiq/blob/main/CHANGELOG.md"
|
19
|
-
|
20
|
-
# Specify which files should be added to the gem when it is released.
|
21
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
-
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
24
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor|Rakefile)})
|
25
|
-
end
|
26
|
-
end
|
27
|
-
spec.bindir = "exe"
|
28
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
-
spec.require_paths = ["lib"]
|
30
|
-
|
31
|
-
spec.add_dependency "logcraft"
|
32
|
-
spec.add_dependency "sidekiq", "~> 6.0"
|
33
|
-
|
34
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
35
|
-
spec.add_development_dependency "rake", ">= 12.0"
|
36
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
-
end
|