rack-key_value_logger 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class KeyValueLogger
3
- VERSION = '0.3.1'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
1
  require 'logger'
2
2
  require 'multi_json'
3
+ require 'active_support/time'
3
4
 
4
5
  module Rack
5
6
  class KeyValueLogger
@@ -67,6 +68,7 @@ module Rack
67
68
  end
68
69
 
69
70
  # record request attributes
71
+ msg << "ts=#{Time.now.utc.iso8601}"
70
72
  msg << "method=#{request.request_method}"
71
73
  msg << "url=#{url}"
72
74
  msg << "params=#{query_string}"
@@ -115,9 +117,6 @@ module Rack
115
117
  # Flush `msg` to the logger instance.
116
118
  def flush_log
117
119
  result = msg.join(SEPARATOR)
118
- now = Time.now
119
- result = "[#{now.to_i} #{now.utc}] " + result
120
-
121
120
  logger.info result
122
121
  end
123
122
 
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_dependency 'multi_json'
23
23
  s.add_dependency 'rack'
24
+ s.add_dependency 'activesupport'
24
25
  end
@@ -58,6 +58,7 @@ describe "logging non success response bodies" do
58
58
  end
59
59
 
60
60
  it_behaves_like "it logs", 'status', 200
61
+ it_behaves_like "it logs", 'ts', Time.now.utc.iso8601
61
62
 
62
63
  it 'does not log the response body for success endpoints' do
63
64
  drain.should_not include_entry 'response_body=Unauthorized'
@@ -70,6 +71,7 @@ describe "logging non success response bodies" do
70
71
  end
71
72
 
72
73
  it_behaves_like 'it logs', 'status', 400
74
+ it_behaves_like "it logs", 'ts', Time.now.utc.iso8601
73
75
  end
74
76
 
75
77
  context 'an unexpected 500 response' do
@@ -84,6 +86,7 @@ describe "logging non success response bodies" do
84
86
 
85
87
  it_behaves_like 'it logs', 'url', '/500'
86
88
  it_behaves_like 'it logs', 'status', 500
89
+ it_behaves_like "it logs", 'ts', Time.now.utc.iso8601
87
90
  end
88
91
  end
89
92
 
@@ -120,5 +123,6 @@ describe "ignoring certain paths" do
120
123
 
121
124
  it_behaves_like 'it logs', 'status', '200'
122
125
  it_behaves_like 'it logs', 'url', '/do-not-ignore'
126
+ it_behaves_like "it logs", 'ts', Time.now.utc.iso8601
123
127
  end
124
- end
128
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-key_value_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-27 00:00:00.000000000 Z
12
+ date: 2013-04-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: activesupport
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  description: Structured, key-value logging for your rack apps. Inspired by lograge.
47
63
  email:
48
64
  - ajsharp@gmail.com
@@ -83,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
99
  version: '0'
84
100
  requirements: []
85
101
  rubyforge_project: rack-key_value_logger
86
- rubygems_version: 1.8.24
102
+ rubygems_version: 1.8.25
87
103
  signing_key:
88
104
  specification_version: 3
89
105
  summary: Structured, key-value logging for your rack apps.