betterlog 0.11.0 → 0.12.0

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: 93ac0b92fff87f8005af14b59044b35a17981c2fd30ca1a3614d52967cf711b8
4
- data.tar.gz: 22756efdebaa24185c28ffa2ba76cec177e83177f94b874d4bac13c3d8d87ac5
3
+ metadata.gz: 881c76f1faf7c6783210c43f1c4c720d43cfc794da8385c27267080325f01af2
4
+ data.tar.gz: 6e266178a87eb7c1f526bcb9a70fc13b5bfc5ff642d8b2a63b0bb95e4b43053b
5
5
  SHA512:
6
- metadata.gz: f4f4313920141cf7b4549da03362eb1ac585a8ac6f8d6bd80bc95cbff178797f507267ae9c9b56ab2423271c0a69dc5e9c3f0cb4c8454c7ff6824530ede26c8d
7
- data.tar.gz: 2626a52f7915d4a2699cfcbde0425a736e5c41d1fefb03e13adefaa44961f1f118ac44921f37f34fe9adb7a65b3ee03b145d3cb331e9ca7ac4e6909ca1a45097
6
+ metadata.gz: 3036a50353157aece676091b0f245cbe30976fd707a214863546768bf3a20aa736c016c0e730f7cca11817fb410e293a40f20e2999620e6350b183d531e6d069
7
+ data.tar.gz: 4abee0552ed87ff53b35f562d5306c8edd24b18e45f4deed25e2b33098b9dea0d57e911f0a4b3914187c94f483557a163d3833ce1e386f1a63fc043b0dc53054
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.0
1
+ 0.12.0
data/betterlog.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: betterlog 0.11.0 ruby lib
2
+ # stub: betterlog 0.12.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "betterlog".freeze
6
- s.version = "0.11.0"
6
+ s.version = "0.12.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
data/lib/betterlog/log.rb CHANGED
@@ -90,10 +90,12 @@ module Betterlog
90
90
  #
91
91
  # @param name the name of the recorded metric.
92
92
  # @param value of the recorded metric, defaults to duration if block was given.
93
+ # @param success a Proc with parameter +result+ that returns true iff block
94
+ # result was asuccessful
93
95
  # @param **rest additional rest is logged as well.
94
96
  # @return [ Log ] this object itself.
95
- def metric(name:, value: nil, **rest, &block)
96
- time_block(&block)
97
+ def metric(name:, value: nil, success: -> result { true }, **rest, &block)
98
+ result = time_block(&block)
97
99
  rescue => error
98
100
  e = Log::Event.ify(error)
99
101
  rest |= e.as_hash.subhash(:error_class, :backtrace, :message)
@@ -107,6 +109,7 @@ module Betterlog
107
109
  event = build_metric(
108
110
  name: name,
109
111
  value: value || timed_duration,
112
+ success: success.(result),
110
113
  **rest
111
114
  )
112
115
  emit event
@@ -1,6 +1,6 @@
1
1
  module Betterlog
2
2
  # Betterlog version
3
- VERSION = '0.11.0'
3
+ VERSION = '0.12.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -147,6 +147,7 @@ describe Betterlog::Log do
147
147
  message: 'a metric controller.action=0.123',
148
148
  name: 'controller.action',
149
149
  value: 0.123,
150
+ success: true,
150
151
  type: 'metric',
151
152
  severity: 'info'
152
153
  )
@@ -159,6 +160,7 @@ describe Betterlog::Log do
159
160
  message: 'a metric controller.action=0.123',
160
161
  name: 'controller.action',
161
162
  value: 0.123,
163
+ success: true,
162
164
  type: 'metric',
163
165
  severity: :info,
164
166
  )
@@ -172,6 +174,7 @@ describe Betterlog::Log do
172
174
  foo: 'bar',
173
175
  name: 'controller.action',
174
176
  value: 0.123,
177
+ success: true,
175
178
  type: 'metric',
176
179
  severity: 'info'
177
180
  )
@@ -184,14 +187,16 @@ describe Betterlog::Log do
184
187
  message: 'a metric foo=10.0',
185
188
  name: 'foo',
186
189
  value: 10.0,
190
+ success: true,
187
191
  duration: 10.0,
188
192
  timestamp: "2011-11-11T10:11:21.000Z",
189
193
  type: 'metric',
190
194
  severity: 'info'
191
195
  )
192
196
  expect(instance).to receive(:emit).with(expected_event)
193
- Log.metric(name: 'foo') do
197
+ Log.metric(name: 'foo', success: -> result { result == :success }) do
194
198
  Time.dummy = Time.now + 10
199
+ :success
195
200
  end
196
201
  end
197
202
 
@@ -205,6 +210,7 @@ describe Betterlog::Log do
205
210
  expected_event = Log::Event.new(
206
211
  name: 'foo',
207
212
  value: 3.0,
213
+ success: false,
208
214
  duration: 3.0,
209
215
  timestamp: "2011-11-11T10:11:14.000Z",
210
216
  message: '"MyEx: we were fucked" while measuring metric foo',
@@ -216,10 +222,11 @@ describe Betterlog::Log do
216
222
  expect(instance).to receive(:emit).with(expected_event)
217
223
  raised = false
218
224
  begin
219
- Log.metric(name: 'foo') do
225
+ Log.metric(name: 'foo', success: -> result { result == :success }) do
220
226
  Time.dummy = Time.now + 3
221
227
  raise MyEx, "we were fucked"
222
228
  Time.dummy = Time.now + 7
229
+ :success
223
230
  end
224
231
  rescue MyEx
225
232
  raised = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betterlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - betterplace Developers