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 +4 -4
- data/lib/ezlog/sidekiq/job_logger.rb +10 -10
- data/lib/ezlog/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a89b74f63f86ae29c07305e46bf13c8947b182e191e47e3f62b7e44871e29b2
|
4
|
+
data.tar.gz: 4fdfa0f12bd2b3329cedbf07a141bae85d33e4330bf0b09cd1f56dec5222e76d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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