sidekiq-logging-json 0.0.15 → 0.0.16

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: 3dc0dc0aab1285f7082c2f61aa4ba999c2877078
4
- data.tar.gz: a89d8f5deba592f594c5d91458123e7231fd275b
3
+ metadata.gz: 3ff0f8dd857e176ed01156393972c0d0937f89d1
4
+ data.tar.gz: 5ce9b30ae414561a2b0b6e72d81be2065c27aae5
5
5
  SHA512:
6
- metadata.gz: 911414f9c0900b0643115095eb1d30395396f6f2504236f5d4ad740ab2906cbb72985e270adf1755aa17a4c83d5c6a26b0fdda498f2fea11f2bb80486758acc1
7
- data.tar.gz: 89bfa7ff96c6536f774a3a9d616199e70078f1f689e7e5bf38946c2b74c9744c95f437f72b44ecc3d3624ea74490333656c4187dea101d09123f669aed04c8be
6
+ metadata.gz: ba590683e12f4fad5dc89c1b446626c7b32cc42b55e700e408758569247788221be36f6c4812cb51f8f8161655a7e1b768d480ebd8e35d53f15b4082d09a65f7
7
+ data.tar.gz: a048483e78df758c1639a290ddafb7c062b16e5eb5c131cfcd7d6532db00bc3e22245591eb208063e7d80022b5743790e92cbc525a4709681072fdac8f6a99c0
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
2
3
 
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -21,34 +21,35 @@ module Sidekiq
21
21
  '@status' => nil,
22
22
  '@severity' => severity,
23
23
  '@run_time' => nil,
24
- '@message' => "#{time.utc.iso8601} #{::Process.pid} TID-#{Thread.current.object_id.to_s(36)}#{context} #{severity}: #{message}",
25
- }.merge(process_message(severity, time, program_name, message)).to_json + "\n"
24
+ }.merge(process_message(message)).to_json + "\n"
26
25
  end
27
26
 
28
- def process_message(severity, time, program_name, message)
29
- return { '@status' => 'exception' } if message.is_a?(Exception)
30
-
31
- if message.is_a? Hash
27
+ def process_message(message)
28
+ case message
29
+ when Exception
30
+ { '@status' => 'exception', '@message' => message.message }
31
+ when Hash
32
32
  if message["retry"]
33
- status = "retry"
34
- msg = "#{message['class']} failed, retrying with args #{message['args']}."
33
+ {
34
+ '@status' => 'retry',
35
+ '@message' => "#{message['class']} failed, retrying with args #{message['args']}."
36
+ }
35
37
  else
36
- status = "dead"
37
- msg = "#{message['class']} failed with args #{message['args']}, not retrying."
38
+ {
39
+ '@status' => 'dead',
40
+ '@message' => "#{message['class']} failed with args #{message['args']}, not retrying."
41
+ }
38
42
  end
39
- return {
40
- '@status' => status,
41
- '@message' => "#{time.utc.iso8601} #{::Process.pid} TID-#{Thread.current.object_id.to_s(36)}#{context} #{severity}: #{msg}"
43
+ else
44
+ result = message.split(" ")
45
+ status = result[0].match(/^(start|done|fail):?$/) || []
46
+
47
+ {
48
+ '@status' => status[1], # start or done
49
+ '@run_time' => status[1] && result[1] && result[1].to_f, # run time in seconds
50
+ '@message' => message
42
51
  }
43
52
  end
44
-
45
- result = message.split(" ")
46
- status = result[0].match(/^(start|done|fail):?$/) || []
47
-
48
- {
49
- '@status' => status[1], # start or done
50
- '@run_time' => status[1] && result[1] && result[1].to_f # run time in seconds
51
- }
52
53
  end
53
54
  end
54
55
  end
@@ -1,7 +1,7 @@
1
1
  module Sidekiq
2
2
  module Logging
3
3
  module Json
4
- VERSION = "0.0.15"
4
+ VERSION = "0.0.16"
5
5
  end
6
6
  end
7
7
  end
@@ -27,5 +27,5 @@ DESC
27
27
  spec.add_development_dependency "rake", "~> 10"
28
28
  spec.add_development_dependency "rspec", "~> 3"
29
29
 
30
- spec.add_runtime_dependency "sidekiq", ">= 3"
30
+ spec.add_runtime_dependency "sidekiq", [">= 3", "< 5"]
31
31
  end
@@ -11,33 +11,33 @@ describe "Sidekiq::Logging::Json" do
11
11
  let(:time) { Time.now }
12
12
  let(:program_name) { "RSpec" }
13
13
 
14
- it { expect( message ).to match(/#{logentry}/) }
15
- it { expect( status ).to eq(nil) }
16
- it { expect( run_time ).to eq(nil) }
14
+ it { expect(message).to match(/#{logentry}/) }
15
+ it { expect(status).to eq(nil) }
16
+ it { expect(run_time).to eq(nil) }
17
17
 
18
18
  context "start" do
19
19
  let(:logentry) { "start" }
20
20
 
21
- it { expect( message ).to match(/#{logentry}/) }
22
- it { expect( status ).to eq("start") }
23
- it { expect( run_time ).to eq(nil) }
21
+ it { expect(message).to match(/#{logentry}/) }
22
+ it { expect(status).to eq("start") }
23
+ it { expect(run_time).to eq(nil) }
24
24
  end
25
25
 
26
26
  context "done" do
27
27
  let(:logentry) { "done: 51.579 sec" }
28
28
 
29
- it { expect( message ).to match(/#{logentry}/) }
30
- it { expect( status ).to eq("done") }
31
- it { expect( run_time ).to eq(51.579) }
29
+ it { expect(message).to match(/#{logentry}/) }
30
+ it { expect(status).to eq("done") }
31
+ it { expect(run_time).to eq(51.579) }
32
32
  end
33
33
 
34
34
  context "exception" do
35
35
  let(:exception_message) { "This is the message that should be logged." }
36
- let(:logentry) { NoMethodError.new( exception_message ) }
36
+ let(:logentry) { NoMethodError.new(exception_message) }
37
37
 
38
- it { expect(message).to match( exception_message ) }
39
- it { expect( status ).to eq("exception") }
40
- it { expect( run_time ).to eq(nil) }
38
+ it { expect(message).to match(exception_message) }
39
+ it { expect(status).to eq("exception") }
40
+ it { expect(run_time).to eq(nil) }
41
41
  end
42
42
 
43
43
  context "retry" do
@@ -45,9 +45,19 @@ describe "Sidekiq::Logging::Json" do
45
45
  {"retry"=>true, "queue"=>"default", "class"=>"MarkTest", "args"=>["markie"], "jid"=>"0ca71f2580fdc0ae19a59063", "enqueued_at"=>1405957471.1871092}
46
46
  end
47
47
 
48
- it { expect(message).to match( "MarkTest failed, retrying." ) }
49
- it { expect( status ).to eq("retry") }
50
- it { expect( run_time ).to eq(nil) }
48
+ it { expect(message).to match("MarkTest failed, retrying.") }
49
+ it { expect(status).to eq("retry") }
50
+ it { expect(run_time).to eq(nil) }
51
+ end
52
+
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
57
+
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) }
51
61
  end
52
62
  end
53
63
  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.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter de Vos
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-06 00:00:00.000000000 Z
12
+ date: 2016-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -60,6 +60,9 @@ dependencies:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '3'
63
+ - - "<"
64
+ - !ruby/object:Gem::Version
65
+ version: '5'
63
66
  type: :runtime
64
67
  prerelease: false
65
68
  version_requirements: !ruby/object:Gem::Requirement
@@ -67,6 +70,9 @@ dependencies:
67
70
  - - ">="
68
71
  - !ruby/object:Gem::Version
69
72
  version: '3'
73
+ - - "<"
74
+ - !ruby/object:Gem::Version
75
+ version: '5'
70
76
  description: |
71
77
  At Springest, we use Logstash to ship all our logs to Elasticsearch. An Elasticsearch index consists of JSON documents.
72
78
  To make it possible to make fine grained queries on Sidekiq logs, we needed logging in JSON format.