ezlog 0.10.2 → 0.10.3

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: 87d8d02b49c53db6341c59ac754514278c34ba88b2aa7d2b6391dee02fddef83
4
- data.tar.gz: db7a2efb57161bac874a8d60747d1a0b9760eda901e069efe8ea6e57beb85308
3
+ metadata.gz: 5a89b74f63f86ae29c07305e46bf13c8947b182e191e47e3f62b7e44871e29b2
4
+ data.tar.gz: 4fdfa0f12bd2b3329cedbf07a141bae85d33e4330bf0b09cd1f56dec5222e76d
5
5
  SHA512:
6
- metadata.gz: e9a7279d5cb5996dbd97b0bf18101b9b176bdb0cd7e7f5a9cc0b6297fb1037243f7fe7ef145f885d8876d3627d2c2930d8ab46fd51640265837e9ab97df66417
7
- data.tar.gz: 6e16681888b8449e75c79a2a74775e153c49e4a3f1dc9e06c5f73a9d0159ca77e03ab5cdda5bcc8f3e00b4bf4c192901976c1130fedb862af666f58da089e6ba
6
+ metadata.gz: 7b7803f8b7d10219752ec93b7f5a462bc34a299047f7f1216673850d1d59ee4211ed4b459427f8b041e6e6dc937abe7a9b2073aadc97077d15b06a6c4ca708cf
7
+ data.tar.gz: 6dac05cf4c985db51560b8191bdb8f33ddfd6645a846d6d5e145184500b9dae8218ca9c9006ff005b2e672373ae4fe8252e2e19e31b356943ad80d85f625fa5c
@@ -5,14 +5,18 @@ module Ezlog
5
5
  class JobLogger
6
6
  include 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
@@ -23,11 +27,11 @@ module Ezlog
23
27
  end
24
28
 
25
29
  def prepare(job_hash, &_block)
26
- old_log_level = logger.level
27
- logger.level = job_hash['log_level'] || logger.level
30
+ old_log_level = @logger.level
31
+ @logger.level = job_hash['log_level'] || @logger.level
28
32
  yield
29
33
  ensure
30
- logger.level = old_log_level
34
+ @logger.level = old_log_level
31
35
  end
32
36
 
33
37
  private
@@ -39,10 +43,6 @@ module Ezlog
39
43
  end_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
40
44
  add_to_log_context duration_sec: (end_time - start_time).round(3)
41
45
  end
42
-
43
- def logger
44
- ::Sidekiq.logger
45
- end
46
46
  end
47
47
  end
48
48
  end
data/lib/ezlog/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ezlog
2
- VERSION = '0.10.2'
2
+ VERSION = '0.10.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ezlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoltan Ormandi