sidekiq-logging-json 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/sidekiq/logging/json.rb +7 -4
- data/lib/sidekiq/logging/json/version.rb +1 -1
- data/sidekiq-logging-json.gemspec +2 -2
- data/spec/sidekiq/logging/json_spec.rb +63 -46
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03cd71e6c21bb683257e7aaf1c128ca6b5681162
|
4
|
+
data.tar.gz: b92630293df56537d41fbaf7b6be325509c2a16f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d0cdced997fb5ad78700c11d9a75e25d717cfa0e0a73fb32c2d3e7c264f0293704f2b0b532f841a9c4d9f4c24c854b7b6134a7a043c336df549b94052364dab
|
7
|
+
data.tar.gz: e5b4fd9fc7fbe6716bcc4a9dc958d1ed2254b5e112d735bf847648827465f71ab959ba93fff208d6a555dc0fdfe0625b77459a1c566676481892181a70348f4f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### v0.0.19
|
2
|
+
* Made sure the `sidekiq` gem itself is required first to resolve loading
|
3
|
+
errors. Thanks @dansajner !
|
4
|
+
* General code cleanup (specs, removed unnecessary requires, relaxed
|
5
|
+
development gem version requirements)
|
6
|
+
|
1
7
|
### v0.0.18
|
2
8
|
* Updated Sidekiq dependency so it works with 3 and higher
|
3
9
|
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ Sidekiq.logger.formatter = Sidekiq::Logging::Json::Logger.new
|
|
53
53
|
|
54
54
|
## Contributing
|
55
55
|
|
56
|
-
1. Fork it ( https://github.com/
|
56
|
+
1. Fork it ( https://github.com/springest/sidekiq-logging-json/fork )
|
57
57
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
58
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
59
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/sidekiq/logging/json.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
+
require "sidekiq"
|
1
2
|
require "sidekiq/logging/json/version"
|
2
|
-
require "sidekiq/logging/json"
|
3
|
-
require "json"
|
4
3
|
|
5
4
|
module Sidekiq
|
6
5
|
module Logging
|
7
6
|
module Json
|
8
7
|
class Logger < Sidekiq::Logging::Pretty
|
9
|
-
# Provide a call() method that returns the formatted message.
|
10
8
|
def call(severity, time, program_name, message)
|
11
9
|
{
|
12
10
|
'@timestamp' => time.utc.iso8601,
|
@@ -24,10 +22,15 @@ module Sidekiq
|
|
24
22
|
}.merge(process_message(message)).to_json + "\n"
|
25
23
|
end
|
26
24
|
|
25
|
+
private
|
26
|
+
|
27
27
|
def process_message(message)
|
28
28
|
case message
|
29
29
|
when Exception
|
30
|
-
{
|
30
|
+
{
|
31
|
+
'@status' => 'exception',
|
32
|
+
'@message' => message.message
|
33
|
+
}
|
31
34
|
when Hash
|
32
35
|
if message["retry"]
|
33
36
|
{
|
@@ -23,8 +23,8 @@ DESC
|
|
23
23
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler"
|
27
|
-
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "bundler"
|
27
|
+
spec.add_development_dependency "rake"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3"
|
29
29
|
|
30
30
|
spec.add_runtime_dependency "sidekiq", ">= 3"
|
@@ -1,63 +1,80 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Sidekiq::Logging::Json" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
let(:run_time) { subject["@run_time"] }
|
10
|
-
let(:severity) { "INFO" }
|
11
|
-
let(:time) { Time.now }
|
12
|
-
let(:program_name) { "RSpec" }
|
13
|
-
|
14
|
-
it { expect(message).to match(/#{logentry}/) }
|
15
|
-
it { expect(status).to eq(nil) }
|
16
|
-
it { expect(run_time).to eq(nil) }
|
4
|
+
subject do
|
5
|
+
logger = Sidekiq::Logging::Json::Logger.new
|
6
|
+
result = logger.call(severity, time, program_name, logentry)
|
7
|
+
JSON.parse(result)
|
8
|
+
end
|
17
9
|
|
18
|
-
|
19
|
-
|
10
|
+
let(:logentry) { "Some random message" }
|
11
|
+
let(:message) { subject["@message"] }
|
12
|
+
let(:status) { subject["@status"] }
|
13
|
+
let(:run_time) { subject["@run_time"] }
|
14
|
+
let(:severity) { "INFO" }
|
15
|
+
let(:time) { Time.now }
|
16
|
+
let(:program_name) { "RSpec" }
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
18
|
+
it { expect(message).to eq "Some random message" }
|
19
|
+
it { expect(status).to eq(nil) }
|
20
|
+
it { expect(run_time).to eq(nil) }
|
25
21
|
|
26
|
-
|
27
|
-
|
22
|
+
context "start" do
|
23
|
+
let(:logentry) { "start" }
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
it { expect(message).to eq("start") }
|
26
|
+
it { expect(status).to eq("start") }
|
27
|
+
it { expect(run_time).to eq(nil) }
|
28
|
+
end
|
33
29
|
|
34
|
-
|
35
|
-
|
36
|
-
let(:logentry) { NoMethodError.new(exception_message) }
|
30
|
+
context "done" do
|
31
|
+
let(:logentry) { "done: 51.579 sec" }
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
it { expect(message).to eq("done: 51.579 sec") }
|
34
|
+
it { expect(status).to eq("done") }
|
35
|
+
it { expect(run_time).to eq(51.579) }
|
36
|
+
end
|
42
37
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
38
|
+
context "exception" do
|
39
|
+
let(:exception_message) { "This is the message that should be logged." }
|
40
|
+
let(:logentry) { NoMethodError.new(exception_message) }
|
47
41
|
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
it { expect(message).to eq(exception_message) }
|
43
|
+
it { expect(status).to eq("exception") }
|
44
|
+
it { expect(run_time).to eq(nil) }
|
45
|
+
end
|
46
|
+
|
47
|
+
context "retry" do
|
48
|
+
let(:logentry) do
|
49
|
+
{
|
50
|
+
"retry"=>true,
|
51
|
+
"queue"=>"default",
|
52
|
+
"class"=>"LogTest",
|
53
|
+
"args"=>["argument_1"],
|
54
|
+
"jid"=>"0ca71f2580fdc0ae19a59063",
|
55
|
+
"enqueued_at"=>1405957471.1871092
|
56
|
+
}
|
51
57
|
end
|
52
58
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
59
|
+
it { expect(message).to eq("LogTest failed, retrying with args [\"argument_1\"].") }
|
60
|
+
it { expect(status).to eq("retry") }
|
61
|
+
it { expect(run_time).to eq(nil) }
|
62
|
+
end
|
57
63
|
|
58
|
-
|
59
|
-
|
60
|
-
|
64
|
+
context "dead" do
|
65
|
+
let(:logentry) do
|
66
|
+
{
|
67
|
+
"retry"=>false,
|
68
|
+
"queue"=>"default",
|
69
|
+
"class"=>"LogTest",
|
70
|
+
"args"=>["argument_1"],
|
71
|
+
"jid"=>"0ca71f2580fdc0ae19a59063",
|
72
|
+
"enqueued_at"=>1405957471.1871092
|
73
|
+
}
|
61
74
|
end
|
75
|
+
|
76
|
+
it { expect(message).to eq("LogTest failed with args [\"argument_1\"], not retrying.") }
|
77
|
+
it { expect(status).to eq("dead") }
|
78
|
+
it { expect(run_time).to eq(nil) }
|
62
79
|
end
|
63
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-logging-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wouter de Vos
|
@@ -9,36 +9,36 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.6.14.3
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Sidekiq JSON log format, e.g. for Logstash.
|