lograge 0.9.0 → 0.10.0

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
- SHA1:
3
- metadata.gz: 6c2af15f529c6ed8ac38b2ac369f9f4219f4d6d1
4
- data.tar.gz: 73939dbdbd086eff89fc0b670863d3f4086d0f91
2
+ SHA256:
3
+ metadata.gz: 90e32e509e2b788089246d22c8755d69d495d54f807a8e52e3e0fee3406a448c
4
+ data.tar.gz: 1f969f77c0d5b3878e8a090be723888ba037f982d9688b12ace2f672ce450d9f
5
5
  SHA512:
6
- metadata.gz: 64727cc9391dc0a896c6cc9a473ea79bd68cc370b9c6b0a830a15d7a20bc3434b978940808fe11fb9b02aa45c5343dcc7c77998072577ea243f6a8afc26ce5f9
7
- data.tar.gz: 6e67fcfbbee0e9ca0f069d76bbea563b3333e4ff3aac09437917ae33ef7796af2d82bf1f585abb8d33b566385b97d4f904c05a8aa35cf99972d000b5324ac44b
6
+ metadata.gz: b253f8a2a86557ed264df935b94379f61ef90c426d83d901672c4deef286e40a934c9e596f23ddf22195d8549207ce213ea67a35a039008ace6202c0b131f29b
7
+ data.tar.gz: 0112025bfd732a2b41a52c8325e5cc090b94c2056f2d819d8afe9491f063d01c7be3950e25a2707de4955d15b5d8ca59368eab5236ef634f9ceb1c3ac301dafe
@@ -2,27 +2,29 @@ module Lograge
2
2
  module Formatters
3
3
  class KeyValue
4
4
  def call(data)
5
- fields = fields_to_display(data)
6
-
7
- event = fields.map { |key| format(key, data[key]) }
8
- event.join(' ')
5
+ fields_to_display(data)
6
+ .map { |key| format(key, data[key]) }
7
+ .join(' ')
9
8
  end
10
9
 
10
+ protected
11
+
11
12
  def fields_to_display(data)
12
13
  data.keys
13
14
  end
14
15
 
15
16
  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 = "'#{value}'"
21
- elsif value.is_a? Float
22
- value = Kernel.format('%.2f', value)
23
- end
17
+ "#{key}=#{parse_value(key, value)}"
18
+ end
19
+
20
+ def parse_value(key, value)
21
+ # Exactly preserve the previous output
22
+ # Parsing this can be ambigious if the error messages contains
23
+ # a single quote
24
+ return "'#{value}'" if key == :error
25
+ return Kernel.format('%.2f', value) if value.is_a? Float
24
26
 
25
- "#{key}=#{value}"
27
+ value
26
28
  end
27
29
  end
28
30
  end
@@ -16,20 +16,31 @@ module Lograge
16
16
  :location
17
17
  ].freeze
18
18
 
19
+ UNWANTED_FIELDS = [
20
+ :controller,
21
+ :action
22
+ ].freeze
23
+
19
24
  def call(data)
20
25
  super(modify_payload(data))
21
26
  end
22
27
 
28
+ protected
29
+
30
+ def fields_to_display(data)
31
+ L2MET_FIELDS + additional_fields(data)
32
+ end
33
+
34
+ def additional_fields(data)
35
+ (data.keys - L2MET_FIELDS) - UNWANTED_FIELDS
36
+ end
37
+
23
38
  def format(key, value)
24
39
  key = "measure#page.#{key}" if value.is_a?(Float)
25
40
 
26
41
  super(key, value)
27
42
  end
28
43
 
29
- def fields_to_display(data)
30
- L2MET_FIELDS + (data.keys - L2MET_FIELDS) - [:controller, :action]
31
- end
32
-
33
44
  def modify_payload(data)
34
45
  data[:source] = source_field(data) if data[:controller] && data[:action]
35
46
 
@@ -53,6 +53,10 @@ module Lograge
53
53
 
54
54
  def extract_path(payload)
55
55
  path = payload[:path]
56
+ strip_query_string(path)
57
+ end
58
+
59
+ def strip_query_string(path)
56
60
  index = path.index('?')
57
61
  index ? path[0, index] : path
58
62
  end
@@ -104,7 +108,7 @@ module Lograge
104
108
  return {} unless location
105
109
 
106
110
  RequestStore.store[:lograge_location] = nil
107
- { location: location }
111
+ { location: strip_query_string(location) }
108
112
  end
109
113
 
110
114
  def extract_unpermitted_params
@@ -1,3 +1,3 @@
1
1
  module Lograge
2
- VERSION = '0.9.0'.freeze
2
+ VERSION = '0.10.0'.freeze
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.9.0
4
+ version: 0.10.0
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: 2018-01-12 00:00:00.000000000 Z
12
+ date: 2018-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.6.14
141
+ rubygems_version: 2.7.3
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Tame Rails' multi-line logging into a single line per request