rack_xrk_log 0.2.3 → 0.2.4

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
2
  SHA1:
3
- metadata.gz: e69c8b3cd6b022e209aaf006a4cd49b63c270bcd
4
- data.tar.gz: 41531f32e80947eb46a38c9b2b82ba093cead031
3
+ metadata.gz: 12ea05beb337bc3d8c200bbb345287f6c6419327
4
+ data.tar.gz: 21e85fe05497a5e0765e778adb2cfc22ce35d2a2
5
5
  SHA512:
6
- metadata.gz: 6056baea39660f788694690644d0178bc31caebb934b36a66379b44a061fa7fe73980283be638954cfed7b49504b936e1857a64879e0742267f3b91e970087e9
7
- data.tar.gz: 21f2a5b5198f8f71f1fa892c49d9af9f61c99c1167a9aef3199d5776a76fb6a6fc00b2e323b58721d94d3a7ec90ef0433094e57ef1d31c4667e31fa801202197
6
+ metadata.gz: 87302547e213ff96eaca2cd494d7a13f71423ad3ff02820477f083b73a55ff31ba6168824f6394c4683f9400471fe503ce489fc47afee3ddd7a94c96da17149d
7
+ data.tar.gz: 1a8d673d13927b5c7c164e38ff8ed6c4435b505c29d141945ef354e63a72ccf3be9a01e3db7daf66a562cea19c32e8b09c7399ec2405b2a918cde4d019c322fc
@@ -4,9 +4,14 @@ module Rack
4
4
  attr_accessor :app, :logger, :app_name, :begin_at, :log_type
5
5
 
6
6
  def initialize(app)
7
+ if app.class.parent_name.present?
8
+ app_name = app.class.parent_name.downcase
9
+ else
10
+ app_name = app.class.name.downcase
11
+ end
7
12
  @app = app
8
13
  @log_type = "ACCESS"
9
- @logger = ::Logger.new("log/#{app.parent.name.downcase}_quality_access.log")
14
+ @logger = ::Logger.new("log/#{app_name}_quality_access.log")
10
15
  @logger.formatter = proc do |severity, datetime, progname, msg|
11
16
  "#{begin_at}|#{app_name}|#{log_type}|#{msg}\n"
12
17
  end
@@ -18,28 +18,25 @@ module Rack
18
18
  server_ip_and_port = "#{env['SERVER_NAME']}:#{env['SERVER_PORT']}"
19
19
  query_string = @request.query_string.blank? ? "-" : @request.query_string
20
20
 
21
- binding.pry
22
-
23
21
  [
24
22
  client_ip_and_port,
25
23
  server_ip_and_port,
26
24
  total_runtime,
27
25
  @request.scheme,
28
- query_string.bytesize || 0,
29
- body.bytesize() || 0,
26
+ (query_string.bytesize rescue nil) || 0,
27
+ (body[0].bytesize() rescue nil) || 0,
30
28
  @request.request_method,
31
29
  @request.path_info,
32
30
  status,
33
31
  query_string,
34
32
  path_parameters(env),
35
33
  "-",
36
- json_with_nil(body[0]) || "-"
34
+ (json_with_nil(body[0]) rescue nil) || "-"
37
35
  ].join("|")
38
36
  end
39
37
 
40
-
41
38
  def json_with_nil(value)
42
- JSON.parse(value).to_json rescue nil
39
+ JSON.parse(value).to_json
43
40
  end
44
41
 
45
42
 
data/lib/rack/xrk/log.rb CHANGED
@@ -3,7 +3,7 @@ require 'rack/xrk/log/commonlogger'
3
3
  module Rack
4
4
  module Xrk
5
5
  module Log
6
- VERSION = '0.2.3'
6
+ VERSION = '0.2.4'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack_xrk_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Liu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler