api_hammer 0.2.0 → 0.2.1

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: d674265eaf92948690ef36086f4e6858103e0d92
4
- data.tar.gz: 00af75f0635b6e4fcd1a373936d2524e74852afb
3
+ metadata.gz: 4ae180a72b1ebca9d3f4806d6adb646247900aff
4
+ data.tar.gz: 658496ca213bf67761890117ec56497b534764ed
5
5
  SHA512:
6
- metadata.gz: 91be2d6f0a923086524397f7aed0c00029db8c049f59029cbf9e9c3d0f4754009b76702af132a2797484a80111a24d13eb7b3017367f668389172dabbd882038
7
- data.tar.gz: 6d46171d830d5c41794569e2aa73762fa448b72a831e01d2b146cb6e4850998845eb69048a770bb0c75b80048a895b4aa95e98e1e62ce47f40dacb559d03eb49
6
+ metadata.gz: c83bcc6fb8e5ab284ff7a005a1abb4daa494251cdf8be8e3c5eecf3e81823b5b059c2e615c67e0320cfa208ebec72dd5a001c826a9efe2cb5b83de43f029f71f
7
+ data.tar.gz: 75da8ae6628b64fb630c010dc88a29ff7aef5f1cd7e58c4886a8cf1b8647d4b70511b50ed42f3044f946785db79bcf48a764febed8b7c088900864d5719aa5d2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.2.1
2
+ - small RequestLogger tweaks
3
+
1
4
  # 0.2.0
2
5
  - Rails#unmunged_request_params
3
6
  - hc --pretty
@@ -64,7 +64,6 @@ module ApiHammer
64
64
  'Content-Type' => request.content_type,
65
65
  'remote_addr' => env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"],
66
66
  'User-Agent' => request.user_agent,
67
- 'body' => @request_body,
68
67
  # these come from the OAuthenticator gem/middleware
69
68
  'oauth.authenticated' => env['oauth.authenticated'],
70
69
  'oauth.consumer_key' => env['oauth.consumer_key'],
@@ -77,6 +76,8 @@ module ApiHammer
77
76
  'length' => headers['Content-Length'] || body.to_enum.map(&::Rack::Utils.method(:bytesize)).inject(0, &:+),
78
77
  'Location' => response.location,
79
78
  'Content-Type' => response.content_type,
79
+ # only log response body if there was an error (either client or server)
80
+ 'body' => (400..599).include?(status.to_i) ? body.to_enum.to_a.join('') : nil
80
81
  }.reject{|k,v| v.nil? },
81
82
  'processing' => {
82
83
  'began_at' => began_at.utc.to_i,
@@ -87,7 +88,8 @@ module ApiHammer
87
88
  Thread.current['request_logger.info'] = nil
88
89
  json_data = JSON.dump(data)
89
90
  dolog = proc do
90
- @logger.info "#{status_s} : #{bold(intense_cyan(request.request_method))} #{intense_cyan(request_uri.normalize)}"
91
+ now_s = now.strftime('%Y-%m-%d %H:%M:%S %Z')
92
+ @logger.info "#{status_s} : #{bold(intense_cyan(request.request_method))} #{intense_cyan(request_uri.normalize)} @ #{intense_magenta(now_s)}"
91
93
  @logger.info json_data
92
94
  end
93
95
  # do the logging with tags that applied to the request if appropriate
@@ -1,3 +1,3 @@
1
1
  module ApiHammer
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack