l2meter 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
  SHA1:
3
- metadata.gz: e11fd798f796a3a70084ef2989c0f3d233d55d7f
4
- data.tar.gz: 57141bec2eaee516c4913432720d653f52c3009a
3
+ metadata.gz: a8758c9423aad4f0d392487036c92d4501e6a8fc
4
+ data.tar.gz: 14250d1270dabf5f366ee22c7bbab6dff0e8abcf
5
5
  SHA512:
6
- metadata.gz: 7f0b4f401895a9b09705d488b96451e8f965d862f24f60255a4db401d2ef0f8b87dc45b960815cd3c64878c28cf63fcbdd43c4124e714e0ef39ccd3876417a51
7
- data.tar.gz: ff395e97f4c500d9bd3cada7b0e4ed68af6ae1d8f23eb1bacc16c58217b6cabd197d185b6c3950042e2f254344c7f917bcbe0322a2307a9526d3c916cb77e91e
6
+ metadata.gz: ed94d0f0a82ec17c59e4b57a0598adaac7f0eb6bd2d4662e42bd9ec785a3f563cf56b1ee582bc5fb104b2f676f1ebd161aed76f45ce8c8d37823a8d895a5099b
7
+ data.tar.gz: c53adc609873409a3a9f5edaf3acce2d6732cc811f347a16764ea3a41cee55b01f96cd2567e6a9b2d1597a64c04e3697c701d4bbb5e0d480b06e4cce59cd0936
@@ -80,15 +80,19 @@ module L2meter
80
80
  end
81
81
 
82
82
  def batch
83
+ autoflush = @autoflush
83
84
  @autoflush = false
84
85
  yield
85
86
  ensure
86
- @autoflush = true
87
- fire!
87
+ @autoflush = autoflush
88
+ write
88
89
  end
89
90
 
90
91
  def merge!(*args)
91
- @buffer.merge! format_keys(unwrap(args))
92
+ unwrap(args).each do |key, value|
93
+ key = configuration.key_formatter.call(key)
94
+ @buffer[key] = value
95
+ end
92
96
  end
93
97
 
94
98
  def fire!
@@ -124,7 +128,6 @@ module L2meter
124
128
 
125
129
  def build_token(key, value)
126
130
  value = value.call if Proc === value
127
- return if value.nil?
128
131
  value = scrub_value(key, value)
129
132
  return if value.nil?
130
133
  value == true ? key : "#{key}=#{format_value(value)}"
@@ -149,28 +152,19 @@ module L2meter
149
152
 
150
153
  def format_value(value)
151
154
  case value
152
- when /[^\w,.:@\-\]\[]/
153
- value.strip.gsub(/\s+/, " ").inspect
154
- when String
155
- value.to_s
156
155
  when Float
157
156
  format_float(value)
158
157
  when Time
159
158
  value.iso8601
160
- when Hash
161
- format_value(value.inspect)
162
159
  when Array
163
160
  value.map(&method(:format_value)).join(?,)
164
161
  else
165
- format_value(value.to_s)
162
+ format_string_value(value.to_s)
166
163
  end
167
164
  end
168
165
 
169
- def format_keys(hash)
170
- hash.each_with_object({}) do |(key, value), acc|
171
- key = configuration.key_formatter.call(key)
172
- acc[key] = value
173
- end
166
+ def format_string_value(value)
167
+ value =~ /[^\w,.:@\-\]\[]/ ? value.strip.gsub(/\s+/, " ").inspect : value.to_s
174
168
  end
175
169
 
176
170
  def write(params = nil)
@@ -223,7 +217,7 @@ module L2meter
223
217
  end
224
218
 
225
219
  def scrub_value(key, value)
226
- if scrubber = configuration.scrubber
220
+ if !value.nil? && scrubber = configuration.scrubber
227
221
  scrubber.call(key, value)
228
222
  else
229
223
  value
@@ -1,3 +1,3 @@
1
1
  module L2meter
2
- VERSION = "0.11.0".freeze
2
+ VERSION = "0.12.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: l2meter
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
  - Pavel Pravosud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-26 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  version: '0'
46
46
  requirements: []
47
47
  rubyforge_project:
48
- rubygems_version: 2.6.11
48
+ rubygems_version: 2.6.12
49
49
  signing_key:
50
50
  specification_version: 4
51
51
  summary: L2met friendly log formatter