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 +4 -4
- data/README.md +2 -0
- data/lib/rack/access_log/version.rb +1 -1
- data/lib/rack/access_log.rb +12 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dae28459729c901c9c9879f9bf02ee0fe19dc0f
|
4
|
+
data.tar.gz: bd1e084e02c455ac408b79e397711d7df8b6c0b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/rack/access_log.rb
CHANGED
@@ -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(
|
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?(
|
22
|
-
!@exclude_paths.include?(
|
22
|
+
def tracked?(path_info)
|
23
|
+
!@exclude_paths.include?(path_info)
|
23
24
|
end
|
24
25
|
|
25
|
-
def
|
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.
|
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-
|
11
|
+
date: 2017-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|