betterlog 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7115268bb45a03504abaca3a279b92ac7db2adb1ecbc998c3542425783d84f05
4
- data.tar.gz: 59d9cde12cba986fbaf41a342963d08481f21c7acdbacb4dde266eee4ebfc31b
3
+ metadata.gz: 19d827dd5737b98f60f8e2a6aa64d3f9651d976b2f30a0547154d48e45a893f8
4
+ data.tar.gz: 488821623937b7b5143759afa38ca371cbb5541340423b8ca441e57904c26299
5
5
  SHA512:
6
- metadata.gz: 6aa326b118ace17506694f1448ddb029e4833184b9cd0d015f610b91eb394a85807edc80e7aeb74e993f034f78eecb7b62c90c045357e1e7fb7225994dffe514
7
- data.tar.gz: 22299acccb72b4db01c69e07dcfed18744753011e1af817615bda3e008cade03af214761c0ed8cf640297b907eefbba98601fde770c2e4a0e80ab926cb246748
6
+ metadata.gz: 158de8bb4b4de6006b24d99b4f5cc709c91445438e49479fa55d1dcd52e78ae6153c9039022c92aa2832f88e721b068c82094b32ef054772cd5c6a759ec23a79
7
+ data.tar.gz: 4fface48b8f0a17697b14ed24cfebff578b2621c09a8a15c199aa518cd0d978c2f7423154ccf4c548fbb6ad088b24de79ec35404e1f80a45d980afbf80f53eb9
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.12.1
1
+ 0.12.2
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: betterlog 0.12.1 ruby lib
2
+ # stub: betterlog 0.12.2 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "betterlog".freeze
6
- s.version = "0.12.1"
6
+ s.version = "0.12.2"
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]
10
10
  s.authors = ["betterplace Developers".freeze]
11
- s.date = "2020-04-02"
11
+ s.date = "2020-04-20"
12
12
  s.description = "This library provides structure json logging for our rails projects".freeze
13
13
  s.email = "developers@betterplace.org".freeze
14
14
  s.executables = ["betterlog".freeze, "betterlog_pusher".freeze, "betterlog_sink".freeze]
@@ -98,7 +98,7 @@ module Betterlog
98
98
  result = time_block(&block)
99
99
  rescue => error
100
100
  e = Log::Event.ify(error)
101
- rest |= e.as_hash.subhash(:error_class, :backtrace, :message)
101
+ rest |= e.as_json.subhash(:error_class, :backtrace, :message)
102
102
  rest[:message] = "#{rest[:message].inspect} while measuring metric #{name}"
103
103
  raise error
104
104
  ensure
@@ -125,6 +125,21 @@ module Betterlog
125
125
  instance.context(data_hash)
126
126
  end
127
127
 
128
+ def emit(event)
129
+ l = caller_locations.reverse_each.each_cons(3).find { |c, n1, n2|
130
+ n2.absolute_path =~ /betterlog\/log\.rb/ and break c # TODO check if this still works
131
+ }
132
+ if l
133
+ event[:location] = [ l.absolute_path, l.lineno ] * ?:
134
+ end
135
+ event[:emitter] = self.class.name.downcase
136
+ notify(event)
137
+ logger.send(event.severity.to_sym, event.to_json)
138
+ self
139
+ ensure
140
+ GlobalMetadata.data.clear
141
+ end
142
+
128
143
  private
129
144
 
130
145
  def protect
@@ -158,21 +173,6 @@ module Betterlog
158
173
  )
159
174
  end
160
175
 
161
- def emit(event)
162
- l = caller_locations.reverse_each.each_cons(3).find { |c, n1, n2|
163
- n2.absolute_path =~ /betterlog\/log\.rb/ and break c # TODO check if this still works
164
- }
165
- if l
166
- event[:location] = [ l.absolute_path, l.lineno ] * ?:
167
- end
168
- event[:emitter] = self.class.name.downcase
169
- notify(event)
170
- logger.send(event.severity.to_sym, event.to_json)
171
- self
172
- ensure
173
- GlobalMetadata.data.clear
174
- end
175
-
176
176
  def notify(event)
177
177
  if event.notify?
178
178
  Notifiers.notify(event)
@@ -70,12 +70,12 @@ module Betterlog
70
70
  @data = Hash[data.sort_by(&:first)]
71
71
  end
72
72
 
73
- def as_hash(*a)
73
+ def as_json(*a)
74
74
  @data.dup
75
75
  end
76
76
 
77
77
  def to_json(*a)
78
- as_hash.to_json(*a)
78
+ as_json.to_json(*a)
79
79
  end
80
80
 
81
81
  def format(*args)
@@ -14,7 +14,7 @@ module Betterlog
14
14
 
15
15
  def self.notify(event)
16
16
  notifiers.each do |notifier|
17
- notifier.notify(event.notify?, event.as_hash)
17
+ notifier.notify(event.notify?, event.as_json)
18
18
  end
19
19
  end
20
20
 
@@ -1,6 +1,6 @@
1
1
  module Betterlog
2
2
  # Betterlog version
3
- VERSION = '0.12.1'
3
+ VERSION = '0.12.2'
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:
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Betterlog::Log::Event do
4
- describe '#as_hash' do
4
+ describe '#as_json' do
5
5
  it 'dups hash before returning it' do
6
6
  event = described_class.new
7
- expect(event.as_hash).not_to equal event.instance_variable_get(:@data)
7
+ expect(event.as_json).not_to equal event.instance_variable_get(:@data)
8
8
  end
9
9
  end
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betterlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - betterplace Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2020-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar