lograge 0.3.3 → 0.3.4

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: 38604327cb4f55c74d123cffc28d5fc628f7c6a3
4
- data.tar.gz: 98f4f1c943fce2365c6bc62df996945dcf46ba0a
3
+ metadata.gz: b0ffc5818b2ecfea5d750c2d0e82ffbfca2114dd
4
+ data.tar.gz: 18937487f75539149f07e6f35eadb31b8e8485d4
5
5
  SHA512:
6
- metadata.gz: 21d8263d547c05a350e4da8f56c61315364eb843ad340fdf7415b163cad06acb331a18a42ac6b63d43526b3cece891a5fb447648e57b4ef7c12ee7c6f06702f2
7
- data.tar.gz: 966bdf892a46e78688f888e8f71d17d9b8f53866d6565802d09e8316405080eae96c89449bd1932bb62ef84089aaf1143099f32a2563eed624c55c952e5e6738
6
+ metadata.gz: ba756dfa89f7112bf6677b1c5be3b495a629e8fec32a10f52c07aec06637c15e63df55d30d33dfc27db3113c9043ddd91c2aa15cc8b26bc439a57b7844b1ef53
7
+ data.tar.gz: 2fec943a32467da1728ae77aba093e8e6d8a9fde4b4b7bd3a6b6a07dbe5acc28b7234b4914b43ed486449a81770218666c42ba24107c5325a6e682cc5a76ae9e
@@ -6,6 +6,7 @@ require 'lograge/formatters/key_value'
6
6
  require 'lograge/formatters/l2met'
7
7
  require 'lograge/formatters/lines'
8
8
  require 'lograge/formatters/logstash'
9
+ require 'lograge/formatters/ltsv'
9
10
  require 'lograge/formatters/raw'
10
11
  require 'lograge/log_subscriber'
11
12
  require 'active_support/core_ext/module/attribute_accessors'
@@ -0,0 +1,43 @@
1
+ module Lograge
2
+ module Formatters
3
+ class LTSV
4
+ def call(data)
5
+ fields = fields_to_display(data)
6
+
7
+ event = fields.map { |key| format(key, data[key]) }
8
+ event.join('\t')
9
+ end
10
+
11
+ def fields_to_display(data)
12
+ data.keys
13
+ end
14
+
15
+ def format(key, value)
16
+ if key == :error
17
+ # Exactly preserve the previous output
18
+ # Parsing this can be ambigious if the error messages contains
19
+ # a single quote
20
+ value = "'#{escape value}'"
21
+ else
22
+ # Ensure that we always have exactly two decimals
23
+ value = Kernel.format('%.2f', value) if value.is_a? Float
24
+ end
25
+
26
+ "#{key}:#{value}"
27
+ end
28
+
29
+ private
30
+
31
+ def escape(string)
32
+ value = string.is_a?(String) ? string.dup : string.to_s
33
+
34
+ value.gsub!('\\', '\\\\')
35
+ value.gsub!('\n', '\\n')
36
+ value.gsub!('\r', '\\r')
37
+ value.gsub!('\t', '\\t')
38
+
39
+ value
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module Lograge
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lograge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Meyer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-16 00:00:00.000000000 Z
12
+ date: 2015-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -97,6 +97,7 @@ files:
97
97
  - lib/lograge/formatters/l2met.rb
98
98
  - lib/lograge/formatters/lines.rb
99
99
  - lib/lograge/formatters/logstash.rb
100
+ - lib/lograge/formatters/ltsv.rb
100
101
  - lib/lograge/formatters/raw.rb
101
102
  - lib/lograge/log_subscriber.rb
102
103
  - lib/lograge/rails_ext/rack/logger.rb