trifle-logger 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/trifle/logger/configuration.rb +16 -5
- data/lib/trifle/logger/tracer/hash.rb +31 -4
- data/lib/trifle/logger/tracer/null.rb +4 -0
- data/lib/trifle/logger/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6df3b5ac2c9be39829e661fb9793383abdb61999e3fdec1a749f8127736d9fd
|
4
|
+
data.tar.gz: 45645936044b84f02911c731ae346c402ca586368ebe18e1a21705ba5df2bdc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b38fa3326d9e49f32a0831556775a47df90082837ce5764e5388b2adce820f4b55e198a8660c899662ab3adff503b8434b2253699930a377785a65cced634079
|
7
|
+
data.tar.gz: 14e02a5990b21aed720a7ffc348e71d67cc21e1080069628c2299cee2793260ab8afc002d78f4c1557dec8b82561d5c1e8d8fa6554398e4ee76040a404979203
|
data/Gemfile.lock
CHANGED
@@ -3,17 +3,28 @@
|
|
3
3
|
module Trifle
|
4
4
|
module Logger
|
5
5
|
class Configuration
|
6
|
-
attr_accessor :tracer_klass, :callbacks
|
6
|
+
attr_accessor :tracer_klass, :callbacks, :bump_every
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@tracer_klass = Trifle::Logger::Tracer::Hash
|
10
|
-
@callbacks = {
|
11
|
-
|
12
|
-
|
10
|
+
@callbacks = { liftoff: [], bump: [], wrapup: [] }
|
11
|
+
@bump_every = 15.seconds
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_liftoff(tracer)
|
15
|
+
@callbacks.fetch(:liftoff, []).map do |c|
|
16
|
+
c.call(tracer)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def on_bump(tracer)
|
21
|
+
@callbacks.fetch(:bump, []).map do |c|
|
22
|
+
c.call(tracer)
|
23
|
+
end
|
13
24
|
end
|
14
25
|
|
15
26
|
def on_wrapup(tracer)
|
16
|
-
@callbacks.fetch(:wrapup, []).
|
27
|
+
@callbacks.fetch(:wrapup, []).map do |c|
|
17
28
|
c.call(tracer)
|
18
29
|
end
|
19
30
|
end
|
@@ -4,7 +4,7 @@ module Trifle
|
|
4
4
|
module Logger
|
5
5
|
module Tracer
|
6
6
|
class Hash
|
7
|
-
attr_accessor :key, :meta, :data, :tags, :artifacts, :state, :ignore
|
7
|
+
attr_accessor :key, :meta, :data, :tags, :artifacts, :state, :ignore, :reference
|
8
8
|
|
9
9
|
def initialize(key:, meta: nil)
|
10
10
|
@key = key
|
@@ -12,11 +12,12 @@ module Trifle
|
|
12
12
|
@data = []
|
13
13
|
@tags = []
|
14
14
|
@artifacts = []
|
15
|
-
@state = :
|
15
|
+
@state = :running
|
16
16
|
@ignore = false
|
17
17
|
@result_prefix = '=> '
|
18
18
|
|
19
19
|
trace("Trifle::Trace has been initialized for #{key}")
|
20
|
+
@reference = liftoff.first
|
20
21
|
end
|
21
22
|
|
22
23
|
def keys
|
@@ -24,7 +25,7 @@ module Trifle
|
|
24
25
|
parts.count.times.map { |i| parts[0..i].join('/') }
|
25
26
|
end
|
26
27
|
|
27
|
-
def trace(message, state: :success, head: false)
|
28
|
+
def trace(message, state: :success, head: false) # rubocop:disable Metrics/MethodLength
|
28
29
|
result = yield if block_given?
|
29
30
|
rescue => e # rubocop:disable Style/RescueStandardError
|
30
31
|
raise e
|
@@ -34,6 +35,7 @@ module Trifle
|
|
34
35
|
head: head, state: block_given? && result.nil? || e ? :error : state
|
35
36
|
)
|
36
37
|
dump_result(result) if block_given?
|
38
|
+
bump
|
37
39
|
result
|
38
40
|
end
|
39
41
|
|
@@ -57,6 +59,8 @@ module Trifle
|
|
57
59
|
|
58
60
|
def tag(tag)
|
59
61
|
@tags << tag
|
62
|
+
bump
|
63
|
+
tag
|
60
64
|
end
|
61
65
|
|
62
66
|
def artifact(name, path)
|
@@ -65,6 +69,8 @@ module Trifle
|
|
65
69
|
state: :success, head: false, meta: false, media: true
|
66
70
|
}
|
67
71
|
@artifacts << path
|
72
|
+
bump
|
73
|
+
path
|
68
74
|
end
|
69
75
|
|
70
76
|
def fail!
|
@@ -75,16 +81,37 @@ module Trifle
|
|
75
81
|
@state = :warning
|
76
82
|
end
|
77
83
|
|
84
|
+
def success!
|
85
|
+
@state = :success
|
86
|
+
end
|
87
|
+
|
78
88
|
def success?
|
79
89
|
@state == :success
|
80
90
|
end
|
81
91
|
|
92
|
+
def running?
|
93
|
+
@state == :running
|
94
|
+
end
|
95
|
+
|
82
96
|
def ignore!
|
83
97
|
@ignore = true
|
84
98
|
end
|
85
99
|
|
100
|
+
def liftoff
|
101
|
+
@bumped_at = now
|
102
|
+
Trifle::Logger.default.on_liftoff(self)
|
103
|
+
end
|
104
|
+
|
105
|
+
def bump
|
106
|
+
return unless @bumped_at && @bumped_at <= now - Trifle::Logger.default.bump_every
|
107
|
+
|
108
|
+
@bumped_at = now
|
109
|
+
Trifle::Logger.default.on_bump(self)
|
110
|
+
end
|
111
|
+
|
86
112
|
def wrapup
|
87
|
-
|
113
|
+
success! if running?
|
114
|
+
Trifle::Logger.default.on_wrapup(self)
|
88
115
|
end
|
89
116
|
end
|
90
117
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trifle-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jozef Vaclavik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|