logging_worker 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/logging_worker/job_run.rb +13 -4
- data/lib/logging_worker/version.rb +1 -1
- data/lib/logging_worker/worker.rb +0 -2
- data/spec/models/job_run_spec.rb +1 -0
- data/spec/worker_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cee20c47d414820e4304760caf55d2cf166844cd
|
4
|
+
data.tar.gz: 7cc1fc4d0e0dcae4adc8e714d84a92905727180f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69f459050404932c790158e123c2e82b90b54cf6a573a2331d7f6c3cba3bfabdc4b247a87e8caad9bb17fe7711f40e82648d4ef1fb2ebe125708e8b97fd35ef8
|
7
|
+
data.tar.gz: f7d394a448b46448e1cd43b427b6ea14ce3b4fce7e58aac340a28d5b5765750ef6b49da033cee46362b0cf1d02977a2ccde9c42a571a3b4e29d589e53373c579
|
@@ -5,12 +5,19 @@ class LoggingWorker::JobRun < ApplicationRecord
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def logger
|
8
|
-
@
|
8
|
+
@io ||= StringIO.new
|
9
|
+
@logger ||= Logger.new(@io)
|
9
10
|
end
|
10
11
|
|
11
|
-
def flush_log!
|
12
|
-
|
13
|
-
|
12
|
+
def flush_log!(save_to_db = true)
|
13
|
+
@io.rewind
|
14
|
+
content = @io.read
|
15
|
+
self.log += content
|
16
|
+
save! if save_to_db
|
17
|
+
@io.close
|
18
|
+
@logger.close
|
19
|
+
@io = nil
|
20
|
+
@logger = nil
|
14
21
|
end
|
15
22
|
|
16
23
|
def do_not_record!
|
@@ -27,6 +34,8 @@ class LoggingWorker::JobRun < ApplicationRecord
|
|
27
34
|
else
|
28
35
|
self.successful = false if successful.nil?
|
29
36
|
self.completed_at = Time.now
|
37
|
+
logger # make sure we've got it
|
38
|
+
flush_log!(false)
|
30
39
|
save!
|
31
40
|
end
|
32
41
|
end
|
data/spec/models/job_run_spec.rb
CHANGED
data/spec/worker_spec.rb
CHANGED
@@ -79,9 +79,11 @@ describe LoggingWorker::Worker do
|
|
79
79
|
run.flush_log!
|
80
80
|
expect(LoggingWorker::JobRun.first.log).to include("Test this")
|
81
81
|
expect(LoggingWorker::JobRun.first.log).to include("Testing more")
|
82
|
+
run.logger.info "Testing even more"
|
82
83
|
run.completed!
|
83
84
|
expect(LoggingWorker::JobRun.first.log).to include("Test this")
|
84
85
|
expect(LoggingWorker::JobRun.first.log).to include("Testing more")
|
86
|
+
expect(LoggingWorker::JobRun.first.log).to include("Testing even more")
|
85
87
|
end
|
86
88
|
|
87
89
|
specify "self desctruct on complete" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logging_worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Oestrich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|