httplog 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +34 -10
- data/lib/httplog/configuration.rb +3 -3
- data/lib/httplog/http_log.rb +5 -5
- data/lib/httplog/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ce910d7c04847c28f836de26906c0c50aa4642b553b298d15067bf6ee25db56
|
4
|
+
data.tar.gz: 8600e756f28e033b6e39ac91235f69bf772fe467b05040d88c02ce54e982ef0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a76055079c7bfa4a229fda0861f90276c94cb64859ae7ce3c269e86656f3ad69fb3d5e8ed7eb2b82e9fe1facb0a73619951f099aafbbac7b0b503a52eb21046
|
7
|
+
data.tar.gz: f541eec119d175cc50563bc2673d60dae6246a43bcf570f9fe4db9a6295697ea94f7ffddb709aa8c9d0264f274f48c42bca3322d3364c1edd47298a984421363
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 1.4.3 - 2020-06-10
|
2
|
+
|
3
|
+
* Masking `password` parameter by default... doh.
|
4
|
+
|
5
|
+
## 1.4.2 - 2020-02-09
|
6
|
+
|
7
|
+
* Rollback of the previous two releases due to bugs introduced there.
|
8
|
+
|
1
9
|
## 1.4.1 - 2020-02-08 - YANKED
|
2
10
|
|
3
11
|
* [#91](https://github.com/trusche/httplog/pull/91) Fixed bug returning empty response with HTTP gem
|
data/README.md
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
## httplog
|
2
2
|
|
3
|
-
**VERSION 1.4.0 and 1.4.1 HAVE BEEN YANKED** from rubygems.org due to [this issue](https://github.com/trusche/httplog/issues/89), please update to version 1.4.2. Sorry about that...
|
3
|
+
**VERSION 1.4.0 and 1.4.1 HAVE BEEN YANKED** from rubygems.org due to [this issue](https://github.com/trusche/httplog/issues/89), please update to version 1.4.2 or higher. Sorry about that...
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/httplog.svg)](http://badge.fury.io/rb/httplog) [![Build Status](https://travis-ci.org/trusche/httplog.svg?branch=master)](https://travis-ci.org/trusche/httplog) [![Code Climate](https://codeclimate.com/github/trusche/httplog.svg)](https://codeclimate.com/github/trusche/httplog)
|
6
6
|
[![Release Version](https://img.shields.io/github/release/trusche/httplog.svg)](https://img.shields.io/github/release/trusche/httplog.svg)
|
7
|
+
<a href="https://www.bearer.sh?ref=httplog"><img src="/bearer-badge.png" height="20px"/></a>
|
7
8
|
|
8
9
|
Log outgoing HTTP requests made from your application. Helps with debugging pesky API error responses, or just generally understanding what's going on under the hood.
|
9
10
|
|
10
|
-
Requires ruby >= 2.
|
11
|
+
Requires ruby >= 2.5
|
11
12
|
|
12
13
|
This gem works with the following ruby modules and libraries:
|
13
14
|
|
@@ -31,6 +32,10 @@ This is very much a development and debugging tool; it is **not recommended** to
|
|
31
32
|
use this in a production environment as it is monkey-patching the respective HTTP implementations.
|
32
33
|
You have been warned - use at your own risk.
|
33
34
|
|
35
|
+
Httplog is kindly sponsored by <a href="https://www.bearer.sh?ref=httplog">Bearer.sh</a> - go check them out please!
|
36
|
+
|
37
|
+
<a href="https://www.bearer.sh?ref=httplog"><img src="/bearer-sponsor.png" height="72px" /></a>
|
38
|
+
|
34
39
|
### Installation
|
35
40
|
|
36
41
|
gem install httplog
|
@@ -78,9 +83,6 @@ HttpLog.configure do |config|
|
|
78
83
|
# You can also log in JSON format
|
79
84
|
config.json_log = false
|
80
85
|
|
81
|
-
# For Graylog you can set this to `true`
|
82
|
-
config.graylog = false
|
83
|
-
|
84
86
|
# Prettify the output - see below
|
85
87
|
config.color = false
|
86
88
|
|
@@ -96,6 +98,9 @@ HttpLog.configure do |config|
|
|
96
98
|
# to parse JSON responses
|
97
99
|
config.json_parser = JSON
|
98
100
|
|
101
|
+
# When using graylog, you can supply a formatter here - see below for details
|
102
|
+
config.graylog_formatter = nil
|
103
|
+
|
99
104
|
# Mask the values of sensitive request parameters
|
100
105
|
config.filter_parameters = %w[password]
|
101
106
|
end
|
@@ -131,19 +136,38 @@ HttpLog.configure do |config|
|
|
131
136
|
end
|
132
137
|
```
|
133
138
|
|
139
|
+
For more color options please refer to the [rainbow documentation](https://github.com/sickill/rainbow)
|
140
|
+
|
141
|
+
### Graylog logging
|
142
|
+
|
134
143
|
If you use Graylog and want to use its search features such as "benchmark:>1 AND method:PUT",
|
135
144
|
you can use this configuration:
|
136
145
|
|
137
146
|
```ruby
|
147
|
+
FORMATTER = Lograge::Formatters::KeyValue.new
|
148
|
+
|
138
149
|
HttpLog.configure do |config|
|
139
|
-
config.logger
|
140
|
-
config.logger_method
|
141
|
-
config.severity
|
142
|
-
config.
|
150
|
+
config.logger = <your GELF::Logger>
|
151
|
+
config.logger_method = :add
|
152
|
+
config.severity = GELF::Levels::DEBUG
|
153
|
+
config.graylog_formatter = FORMATTER
|
143
154
|
end
|
144
155
|
```
|
145
156
|
|
146
|
-
|
157
|
+
You also can use GELF Graylog format this way:
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
class Lograge::Formatters::Graylog2HttpLog < Lograge::Formatters::Graylog2
|
161
|
+
def short_message data
|
162
|
+
data[:response_body] = data[:response_body].to_s.byteslice(0, 32_766) unless data[:response_body].blank?
|
163
|
+
"[httplog] [#{data[:response_code]}] #{data[:method]} #{data[:url]}"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
FORMATTER = Lograge::Formatters::Graylog2HttpLog.new
|
168
|
+
```
|
169
|
+
|
170
|
+
Or define your own class that implements the `call` method
|
147
171
|
|
148
172
|
### Compact logging
|
149
173
|
|
@@ -5,7 +5,7 @@ module HttpLog
|
|
5
5
|
attr_accessor :enabled,
|
6
6
|
:compact_log,
|
7
7
|
:json_log,
|
8
|
-
:
|
8
|
+
:graylog_formatter,
|
9
9
|
:logger,
|
10
10
|
:logger_method,
|
11
11
|
:severity,
|
@@ -31,7 +31,7 @@ module HttpLog
|
|
31
31
|
@enabled = true
|
32
32
|
@compact_log = false
|
33
33
|
@json_log = false
|
34
|
-
@
|
34
|
+
@graylog_formatter = nil
|
35
35
|
@logger = Logger.new($stdout)
|
36
36
|
@logger_method = :log
|
37
37
|
@severity = Logger::Severity::DEBUG
|
@@ -51,7 +51,7 @@ module HttpLog
|
|
51
51
|
@prefix_response_lines = false
|
52
52
|
@prefix_line_numbers = false
|
53
53
|
@json_parser = JSON
|
54
|
-
@filter_parameters = []
|
54
|
+
@filter_parameters = %w[password]
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
data/lib/httplog/http_log.rb
CHANGED
@@ -32,7 +32,7 @@ module HttpLog
|
|
32
32
|
parse_request(options)
|
33
33
|
if config.json_log
|
34
34
|
log_json(options)
|
35
|
-
elsif config.
|
35
|
+
elsif config.graylog_formatter
|
36
36
|
log_graylog(options)
|
37
37
|
elsif config.compact_log
|
38
38
|
log_compact(options[:method], options[:url], options[:response_code], options[:benchmark])
|
@@ -207,8 +207,6 @@ module HttpLog
|
|
207
207
|
|
208
208
|
def log_graylog(data)
|
209
209
|
result = json_payload(data)
|
210
|
-
|
211
|
-
result[:short_message] = result.delete(:url)
|
212
210
|
begin
|
213
211
|
send_to_graylog result
|
214
212
|
rescue
|
@@ -219,7 +217,8 @@ module HttpLog
|
|
219
217
|
end
|
220
218
|
|
221
219
|
def send_to_graylog data
|
222
|
-
|
220
|
+
data.compact!
|
221
|
+
config.logger.public_send(config.logger_method, config.severity, config.graylog_formatter.call(data))
|
223
222
|
end
|
224
223
|
|
225
224
|
def json_payload(data = {})
|
@@ -264,7 +263,8 @@ module HttpLog
|
|
264
263
|
case msg
|
265
264
|
when *string_classes
|
266
265
|
config.filter_parameters.reduce(msg) do |m,key|
|
267
|
-
m.to_s.
|
266
|
+
scrubbed = m.to_s.encode('UTF-8', invalid: :replace, undef: :replace)
|
267
|
+
scrubbed.gsub(/(#{key})=[^&]+/i, "#{key}=#{PARAM_MASK}")
|
268
268
|
end
|
269
269
|
# ...and recurse over hashes
|
270
270
|
when *hash_classes
|
data/lib/httplog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httplog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thilo Rusche
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ethon
|
@@ -274,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
274
|
- !ruby/object:Gem::Version
|
275
275
|
version: '0'
|
276
276
|
requirements: []
|
277
|
-
rubygems_version: 3.
|
277
|
+
rubygems_version: 3.0.3
|
278
278
|
signing_key:
|
279
279
|
specification_version: 4
|
280
280
|
summary: Log outgoing HTTP requests.
|