lines 0.1.18 → 0.1.19
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 +8 -8
- data/.travis.yml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +4 -1
- data/README.md +2 -0
- data/Rakefile +4 -0
- data/lib/lines.rb +21 -10
- data/lib/lines/version.rb +1 -1
- data/spec/lines_spec.rb +9 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjI0OWIzNjUxNDMzZjFiOGFjYjQ2NWY0YzBiMGFkNGRiNTkyM2Q1YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2EzOWYzNDlmZjkyMGRlZDJkNWFjNGU0NjYyNzU1YTZkYzUwYjlkNg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGY3YTIwMmExZDM0OGI3OTQ4YTA3ZmJiODkyNzUzMzIxMTZiYmFmMWEyYmUy
|
10
|
+
NWM4YTQ4M2VlNjc5ZDlmNmEwZDM2MTZkYWI0NDJiYjA3YjBhZTlhMGI1MDAx
|
11
|
+
YzNkMmMwNmJiZGU0MTc4YjM0MzhkN2VkOGMzZDBiN2U1MmVkZjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTcwMTE4YmIxMmU2MTE3YTZhY2Q5NzNlMDg4NTBhODY5N2MxMTY2NWVjYzli
|
14
|
+
NGNjMzE1ZWFmMDBjNGQ0NTE1NDFhMDY3YWI4MDQ3MDQ0MmMxY2ZjMTliMzU5
|
15
|
+
ZTUxM2Y1OWQ5NmQ5MGQwZThmODNhOWFhYWQwYzkwYWEyODBjOTY=
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lines (0.1.
|
4
|
+
lines (0.1.18)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
@@ -11,6 +11,7 @@ GEM
|
|
11
11
|
json (1.7.7)
|
12
12
|
parslet (1.5.0)
|
13
13
|
blankslate (~> 2.0)
|
14
|
+
rake (0.9.2.2)
|
14
15
|
rdoc (4.0.0)
|
15
16
|
json (~> 1.4)
|
16
17
|
rspec (2.13.0)
|
@@ -26,7 +27,9 @@ PLATFORMS
|
|
26
27
|
ruby
|
27
28
|
|
28
29
|
DEPENDENCIES
|
30
|
+
bundler (~> 1.3)
|
29
31
|
lines!
|
30
32
|
parslet
|
33
|
+
rake
|
31
34
|
rdoc
|
32
35
|
rspec
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
Lines - structured logs for humans
|
2
2
|
==================================
|
3
|
+
[](https://travis-ci.org/zimbatm/lines-ruby)
|
3
5
|
|
4
6
|
An oppinionated logging library that implement the
|
5
7
|
[lines](https://github.com/zimbatm/lines) format.
|
data/Rakefile
ADDED
data/lib/lines.rb
CHANGED
@@ -237,16 +237,24 @@ module Lines
|
|
237
237
|
@mapping[klass] = rule
|
238
238
|
end
|
239
239
|
|
240
|
+
attr_accessor :max_depth
|
241
|
+
|
240
242
|
protected
|
241
243
|
|
242
244
|
attr_reader :mapping
|
243
245
|
|
244
246
|
def initialize
|
245
247
|
@mapping = {}
|
248
|
+
@max_depth = 3
|
246
249
|
end
|
247
250
|
|
248
|
-
def objenc_internal(x)
|
249
|
-
|
251
|
+
def objenc_internal(x, depth=0)
|
252
|
+
depth += 1
|
253
|
+
if depth > max_depth
|
254
|
+
'...'
|
255
|
+
else
|
256
|
+
x.map{|k,v| "#{keyenc(k)}=#{valenc(v, depth)}" }.join(' ')
|
257
|
+
end
|
250
258
|
end
|
251
259
|
|
252
260
|
def keyenc(k)
|
@@ -257,10 +265,10 @@ module Lines
|
|
257
265
|
end
|
258
266
|
end
|
259
267
|
|
260
|
-
def valenc(x)
|
268
|
+
def valenc(x, depth)
|
261
269
|
case x
|
262
|
-
when Hash then objenc(x)
|
263
|
-
when Array then arrenc(x)
|
270
|
+
when Hash then objenc(x, depth)
|
271
|
+
when Array then arrenc(x, depth)
|
264
272
|
when String, Symbol then strenc(x)
|
265
273
|
when Numeric then numenc(x)
|
266
274
|
when Time, Date then timeenc(x)
|
@@ -272,16 +280,19 @@ module Lines
|
|
272
280
|
end
|
273
281
|
end
|
274
282
|
|
275
|
-
def objenc(x)
|
276
|
-
'{' + objenc_internal(x) + '}'
|
283
|
+
def objenc(x, depth)
|
284
|
+
'{' + objenc_internal(x, depth) + '}'
|
277
285
|
end
|
278
286
|
|
279
|
-
def arrenc(a)
|
287
|
+
def arrenc(a, depth)
|
288
|
+
depth += 1
|
280
289
|
# num + unit. Eg: 3ms
|
281
290
|
if a.size == 2 && a.first.kind_of?(Numeric) && is_literal?(a.last.to_s)
|
282
291
|
numenc(a.first) + strenc(a.last)
|
292
|
+
elsif depth > max_depth
|
293
|
+
'[...]'
|
283
294
|
else
|
284
|
-
'[' + a.map{|x| valenc(x)}.join(' ') + ']'
|
295
|
+
'[' + a.map{|x| valenc(x, depth)}.join(' ') + ']'
|
285
296
|
end
|
286
297
|
end
|
287
298
|
|
@@ -320,7 +331,7 @@ module Lines
|
|
320
331
|
end
|
321
332
|
|
322
333
|
def timeenc(t)
|
323
|
-
t.iso8601
|
334
|
+
t.utc.iso8601
|
324
335
|
end
|
325
336
|
|
326
337
|
def is_literal?(s)
|
data/lib/lines/version.rb
CHANGED
data/spec/lines_spec.rb
CHANGED
@@ -95,12 +95,12 @@ describe Lines::Dumper do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it "can dump IO objects" do
|
98
|
-
expect_dump(foo: File.open(__FILE__)).to match(/foo
|
99
|
-
expect_dump(foo: STDOUT).to
|
98
|
+
expect_dump(foo: File.open(__FILE__)).to match(/foo='?#<File:[^>]+>'?/)
|
99
|
+
expect_dump(foo: STDOUT).to match(/^foo=(?:#<IO:<STDOUT>>|'#<IO:fd 1>')$/)
|
100
100
|
end
|
101
101
|
|
102
102
|
it "dumps time as ISO zulu format" do
|
103
|
-
expect_dump(foo: Time.at(1337)).to eq('foo=1970-01-
|
103
|
+
expect_dump(foo: Time.at(1337)).to eq('foo=1970-01-01T00:22:17Z')
|
104
104
|
end
|
105
105
|
|
106
106
|
it "dumps symbols as strings" do
|
@@ -124,6 +124,12 @@ describe Lines::Dumper do
|
|
124
124
|
expect_dump(foo: [3, :ms]).to eq('foo=3ms')
|
125
125
|
expect_dump(foo: [54.2, 's']).to eq('foo=54.2s')
|
126
126
|
end
|
127
|
+
|
128
|
+
it "knows how to handle circular dependencies" do
|
129
|
+
x = {}
|
130
|
+
x[:x] = x
|
131
|
+
expect_dump(x).to eq('x={x={x={...}}}')
|
132
|
+
end
|
127
133
|
end
|
128
134
|
|
129
135
|
describe Lines::UniqueIDs do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Pfenniger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,10 +46,12 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- .rspec
|
49
|
+
- .travis.yml
|
49
50
|
- Gemfile
|
50
51
|
- Gemfile.lock
|
51
52
|
- LICENSE.txt
|
52
53
|
- README.md
|
54
|
+
- Rakefile
|
53
55
|
- lib/lines.rb
|
54
56
|
- lib/lines/active_record.rb
|
55
57
|
- lib/lines/loader.rb
|