rack-access_log 0.1.0 → 0.2.0

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: 56c846d27381681670964c37eb0f18f2b48f5e6a
4
- data.tar.gz: b995a96573a52d908fc9f833dc0644d7683ba295
3
+ metadata.gz: 0dae28459729c901c9c9879f9bf02ee0fe19dc0f
4
+ data.tar.gz: bd1e084e02c455ac408b79e397711d7df8b6c0b2
5
5
  SHA512:
6
- metadata.gz: eab15a1e29481ecaf3d812e330cc7f29acff22bac4b85eb84713596a484ddf646966acea3fde36798c0c5120ce299d315bb8a8655fc90d6a287ec19bc6a78c5f
7
- data.tar.gz: 8f179a2a3d1518a3d683193f031bdf3c8ac6095ec57b426082f1cf65cd4f0fc89f698c324378e88d96a4356e0ce4a80fe89737f46e07e0043592cca21a9e9a11
6
+ metadata.gz: c048deab6d74523616e2bb10d8492ec2ff4c83b9cc25de8af4138e11b58550d5ba26a2e51040b1ae88827d4de1d6a684050bec60773df40d42252b7333e06ea9
7
+ data.tar.gz: 625f3070d267f73e72e4b20910907beec8e9900a2818c956f5bebdad8c48feb2ee3531d532ebef1a7fb72d8df72682918b43af79ddc08787944f8d6ee9d140e9
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Rack::AccessLog
2
2
 
3
+ [![Build Status](https://travis-ci.org/emartech/rack-access_log.svg?branch=master)](https://travis-ci.org/emartech/rack-access_log)
4
+
3
5
  This is a middleware for ruby / rack based webservice access logging.
4
6
  The implementation doesn't depend on any webframework or monkey patch.
5
7
 
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class AccessLog
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -11,24 +11,30 @@ module Rack
11
11
  end
12
12
 
13
13
  def call(env)
14
+ message_base = create_log_message_base(env)
14
15
  status, header, body_lines, realtime = next_middleware_call_with_benchmarking(env)
15
- @logger.info(create_log_message(env, status, realtime)) if tracked?(env)
16
+ @logger.info(message_base.merge(statistics_from(status, realtime))) if tracked?(message_base[:request_path])
16
17
  [status, header, body_lines]
17
18
  end
18
19
 
19
20
  private
20
21
 
21
- def tracked?(env)
22
- !@exclude_paths.include?(env[Rack::PATH_INFO])
22
+ def tracked?(path_info)
23
+ !@exclude_paths.include?(path_info)
23
24
  end
24
25
 
25
- def create_log_message(env, status, realtime)
26
+ def create_log_message_base(env)
26
27
  {
27
- execution_time_sec: realtime,
28
28
  remote_ip: remote_ip_by(env),
29
- request_method: env[Rack::REQUEST_METHOD],
30
29
  request_path: env[Rack::PATH_INFO],
31
30
  query_string: env[Rack::QUERY_STRING],
31
+ request_method: env[Rack::REQUEST_METHOD]
32
+ }
33
+ end
34
+
35
+ def statistics_from(status, realtime)
36
+ {
37
+ execution_time_sec: realtime,
32
38
  response_status_code: status.to_i
33
39
  }
34
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-access_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-30 00:00:00.000000000 Z
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack