heavylog 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
  SHA256:
3
- metadata.gz: 9cfa2f8bd9f2b151619ba8ce2a529f0ffefd366160dd254a16ec1a726d91737e
4
- data.tar.gz: f70791679b5b64f72f07aa683903f8148600247101734a4dfc08729b2cef57ba
3
+ metadata.gz: 14234701b389d0f983d0195b56bff88b36bd5b20303dde3831e24c09c1413857
4
+ data.tar.gz: d64b00d6db92f63d676c245259dd40bf32e0aa86a4390d5603eacd66d06ac31c
5
5
  SHA512:
6
- metadata.gz: bdab56ed918860a626b5b884ffbc03f65c7e2f9fa35f5bfbfc1d04ac9456f2b340744366a3e27e808fd51e9ace5efca4c249614c595985287fc56e7887a13da2
7
- data.tar.gz: ba4017fdd6edc93e42ed95683e7597b6d2df59f4ee025599988d805a9e41c6fc0db23b819694d05b9b415f6fb34b3888d057da6e2e7c2fc0c311372743d4655e
6
+ metadata.gz: '08f1ce54b82fa3e501535b1d78725f81ae4f2e6a004bba8b75e1b10f954e93473eb25aa3f5a740dd88543438b10b051cafa1c1742e5ee47432a6778d40a3fbc8'
7
+ data.tar.gz: 95f42f4607951a35b499e022028a0f9e4d4d3de063ffe8a9c88d74852827c0b3a3751b3a82affed322d252c193a6a957aee57bc4cc317166e9f4261a49c3047f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- heavylog (0.0.15)
4
+ heavylog (0.0.16)
5
5
  actionpack (>= 5)
6
6
  activesupport (>= 5)
7
7
  railties (>= 5)
@@ -34,16 +34,16 @@ GEM
34
34
  concurrent-ruby (1.1.5)
35
35
  crass (1.0.4)
36
36
  diff-lcs (1.3)
37
- erubi (1.8.0)
38
- i18n (1.6.0)
37
+ erubi (1.9.0)
38
+ i18n (1.7.0)
39
39
  concurrent-ruby (~> 1.0)
40
40
  jaro_winkler (1.5.2)
41
- loofah (2.2.3)
41
+ loofah (2.3.0)
42
42
  crass (~> 1.0.2)
43
43
  nokogiri (>= 1.5.9)
44
44
  method_source (0.9.2)
45
45
  mini_portile2 (2.4.0)
46
- minitest (5.11.3)
46
+ minitest (5.12.2)
47
47
  nokogiri (1.10.4)
48
48
  mini_portile2 (~> 2.4.0)
49
49
  parallel (1.17.0)
@@ -1,64 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Heavylog
4
- class SidekiqLogger
5
- def initialize(logger=Sidekiq.logger)
6
- @logger = logger
7
- end
3
+ require "sidekiq/job_logger"
8
4
 
5
+ module Heavylog
6
+ class SidekiqLogger < Sidekiq::JobLogger
9
7
  def call(item, _queue)
10
8
  # item = {"class"=>"SuspiciousJob", "args"=>[12754545, [3858890], "invoice"], "retry"=>true, "queue"=>"default",
11
9
  # "jid"=>"5ec968571e358497d70a3cf2", "created_at"=>1540484817.3950138, "enqueued_at"=>1540484817.395076}
12
10
 
13
11
  Heavylog.log_sidekiq(item["jid"], item["class"], item["args"])
14
-
15
- begin
16
- start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
17
- @logger.info("start")
18
-
19
- yield
20
-
21
- with_elapsed_time_context(start) do
22
- @logger.info("done")
23
- end
24
-
25
- Heavylog.finish_sidekiq
26
- rescue StandardError
27
- with_elapsed_time_context(start) do
28
- @logger.info("fail")
29
- end
30
-
31
- raise
32
- end
33
- end
34
-
35
- def with_job_hash_context(job_hash, &block)
36
- @logger.with_context(job_hash_context(job_hash), &block)
37
- end
38
-
39
- def job_hash_context(job_hash)
40
- # If we're using a wrapper class, like ActiveJob, use the "wrapped"
41
- # attribute to expose the underlying thing.
42
- h = {
43
- class: job_hash["wrapped"] || job_hash["class"],
44
- jid: job_hash["jid"],
45
- }
46
- h[:bid] = job_hash["bid"] if job_hash["bid"]
47
- h
48
- end
49
-
50
- def with_elapsed_time_context(start, &block)
51
- @logger.with_context(elapsed_time_context(start), &block)
52
- end
53
-
54
- def elapsed_time_context(start)
55
- { elapsed: elapsed(start).to_s }
56
- end
57
-
58
- private
59
-
60
- def elapsed(start)
61
- (::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start).round(3)
12
+ super
13
+ ensure
14
+ Heavylog.finish_sidekiq
62
15
  end
63
16
  end
64
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Heavylog
4
- VERSION = "0.0.15"
4
+ VERSION = "0.0.16"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heavylog
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
  - Kristjan Rang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-16 00:00:00.000000000 Z
11
+ date: 2019-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler