sidekiq-logging-json 0.0.18 → 0.0.19

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
  SHA1:
3
- metadata.gz: bb8f711705c47d1037ccea63b2d4cd60b39ff3bd
4
- data.tar.gz: 4209ac39e4ce4c9dd216016a1ead06bd4bd222ad
3
+ metadata.gz: 03cd71e6c21bb683257e7aaf1c128ca6b5681162
4
+ data.tar.gz: b92630293df56537d41fbaf7b6be325509c2a16f
5
5
  SHA512:
6
- metadata.gz: 7e27dee5aca587510e0131e9e884e5b854b011246046d45f3f4c41b054c272f0688c10b85776dd67c4988f2c5478fa7d294fd28f5ab83de4fcd47ccd32717872
7
- data.tar.gz: 965bb8d30b02661554a45093c1166cfae558f84453ab4432dd70947dccc76efb26b3858fa02954d6501a3e55e015068b99ad3d36e0852aa6ecd5be9cf2d2ad11
6
+ metadata.gz: 8d0cdced997fb5ad78700c11d9a75e25d717cfa0e0a73fb32c2d3e7c264f0293704f2b0b532f841a9c4d9f4c24c854b7b6134a7a043c336df549b94052364dab
7
+ data.tar.gz: e5b4fd9fc7fbe6716bcc4a9dc958d1ed2254b5e112d735bf847648827465f71ab959ba93fff208d6a555dc0fdfe0625b77459a1c566676481892181a70348f4f
@@ -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/[my-github-username]/sidekiq-logging-json/fork )
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`)
@@ -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
- { '@status' => 'exception', '@message' => message.message }
30
+ {
31
+ '@status' => 'exception',
32
+ '@message' => message.message
33
+ }
31
34
  when Hash
32
35
  if message["retry"]
33
36
  {
@@ -1,7 +1,7 @@
1
1
  module Sidekiq
2
2
  module Logging
3
3
  module Json
4
- VERSION = "0.0.18"
4
+ VERSION = "0.0.19"
5
5
  end
6
6
  end
7
7
  end
@@ -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", "~> 1.6"
27
- spec.add_development_dependency "rake", "~> 10"
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
- describe "process_message" do
5
- subject { JSON.parse(Sidekiq::Logging::Json::Logger.new.call(severity, time, program_name, logentry)) }
6
- let(:logentry) { "Some random message" }
7
- let(:message) { subject["@message"] }
8
- let(:status) { subject["@status"] }
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
- context "start" do
19
- let(:logentry) { "start" }
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
- it { expect(message).to match(/#{logentry}/) }
22
- it { expect(status).to eq("start") }
23
- it { expect(run_time).to eq(nil) }
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
- context "done" do
27
- let(:logentry) { "done: 51.579 sec" }
22
+ context "start" do
23
+ let(:logentry) { "start" }
28
24
 
29
- it { expect(message).to match(/#{logentry}/) }
30
- it { expect(status).to eq("done") }
31
- it { expect(run_time).to eq(51.579) }
32
- end
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
- context "exception" do
35
- let(:exception_message) { "This is the message that should be logged." }
36
- let(:logentry) { NoMethodError.new(exception_message) }
30
+ context "done" do
31
+ let(:logentry) { "done: 51.579 sec" }
37
32
 
38
- it { expect(message).to match(exception_message) }
39
- it { expect(status).to eq("exception") }
40
- it { expect(run_time).to eq(nil) }
41
- end
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
- context "retry" do
44
- let(:logentry) do
45
- {"retry"=>true, "queue"=>"default", "class"=>"MarkTest", "args"=>["markie"], "jid"=>"0ca71f2580fdc0ae19a59063", "enqueued_at"=>1405957471.1871092}
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
- it { expect(message).to match("MarkTest failed, retrying.") }
49
- it { expect(status).to eq("retry") }
50
- it { expect(run_time).to eq(nil) }
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
- context "dead" do
54
- let(:logentry) do
55
- {"retry"=>false, "queue"=>"default", "class"=>"MarkTest", "args"=>["markie"], "jid"=>"0ca71f2580fdc0ae19a59063", "enqueued_at"=>1405957471.1871092}
56
- end
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
- it { expect(message).to match("MarkTest failed with args #{logentry["args"]}, not retrying.") }
59
- it { expect(status).to eq("dead") }
60
- it { expect(run_time).to eq(nil) }
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.18
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: 2017-05-12 00:00:00.000000000 Z
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: '1.6'
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: '1.6'
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: '10'
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: '10'
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.5.1
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.