timber 1.1.8 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/timber/events/http_server_request.rb +4 -3
- data/lib/timber/events/http_server_response.rb +1 -1
- data/lib/timber/probes/action_controller_log_subscriber/log_subscriber.rb +1 -1
- data/lib/timber/probes/rails_rack_logger.rb +2 -1
- data/lib/timber/version.rb +1 -1
- data/spec/support/rails.rb +1 -1
- data/spec/timber/probes/rails_rack_logger_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbe987d8fbffcd959912acd47bdca88392cb6639
|
4
|
+
data.tar.gz: 80f5e3d9615a6a1d31f0bf29708a9f14b32f4698
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46c5cf19a12a27e92a8891b340af164429e6983343cfcd2dfb013ebfc167dd714863874ece6350619a7c58a6253cf44059b8d903249ffb35419b5b3d6b027523
|
7
|
+
data.tar.gz: 4f8e29cef3c8337df09f6c05541a67f00f89312eedccc667c692bf0afb7d6d08b9578e361346a336e343c270f25403214f07c7f2ce226e3b2f1bdb6e3195b295
|
@@ -4,9 +4,9 @@ module Timber
|
|
4
4
|
#
|
5
5
|
# @note This event should be installed automatically through probes,
|
6
6
|
# such as the {Probes::ActionControllerLogSubscriber} probe.
|
7
|
-
class
|
7
|
+
class HTTPServerRequest < Timber::Event
|
8
8
|
attr_reader :host, :method, :path, :port, :query_params, :content_type,
|
9
|
-
:remote_addr, :referrer, :request_id, :user_agent
|
9
|
+
:remote_addr, :referrer, :request_id, :scheme, :user_agent
|
10
10
|
|
11
11
|
def initialize(attributes)
|
12
12
|
@host = attributes[:host] || raise(ArgumentError.new(":host is required"))
|
@@ -18,13 +18,14 @@ module Timber
|
|
18
18
|
@remote_addr = attributes[:remote_addr]
|
19
19
|
@referrer = attributes[:referrer]
|
20
20
|
@request_id = attributes[:request_id]
|
21
|
+
@scheme = attributes[:scheme] || raise(ArgumentError.new(":scheme is required"))
|
21
22
|
@user_agent = attributes[:user_agent]
|
22
23
|
end
|
23
24
|
|
24
25
|
def to_hash
|
25
26
|
{host: host, method: method, path: path, port: port, query_params: query_params,
|
26
27
|
headers: {content_type: content_type, remote_addr: remote_addr, referrer: referrer,
|
27
|
-
request_id: request_id, user_agent: user_agent}}
|
28
|
+
request_id: request_id, scheme: scheme, user_agent: user_agent}}
|
28
29
|
end
|
29
30
|
alias to_h to_hash
|
30
31
|
|
@@ -4,7 +4,7 @@ module Timber
|
|
4
4
|
#
|
5
5
|
# @note This event should be installed automatically through probes,
|
6
6
|
# such as the {Probes::ActionControllerLogSubscriber} probe.
|
7
|
-
class
|
7
|
+
class HTTPServerResponse < Timber::Event
|
8
8
|
attr_reader :status, :time_ms, :additions
|
9
9
|
|
10
10
|
def initialize(attributes)
|
@@ -23,7 +23,7 @@ module Timber
|
|
23
23
|
def http_request_event(request)
|
24
24
|
# No idea why rails 3.X returns a "/" :/
|
25
25
|
referrer = request.referer == "/" ? nil : request.referer
|
26
|
-
Events::
|
26
|
+
Events::HTTPServerRequest.new(
|
27
27
|
host: request.host,
|
28
28
|
method: request.request_method,
|
29
29
|
path: request.filtered_path,
|
@@ -33,6 +33,7 @@ module Timber
|
|
33
33
|
remote_addr: request.ip,
|
34
34
|
referrer: referrer,
|
35
35
|
request_id: request_id(request.env),
|
36
|
+
scheme: request.scheme,
|
36
37
|
user_agent: request.user_agent
|
37
38
|
)
|
38
39
|
end
|
data/lib/timber/version.rb
CHANGED
data/spec/support/rails.rb
CHANGED
@@ -2,7 +2,7 @@ require "rails"
|
|
2
2
|
|
3
3
|
# Defualt the rails logger to nothing, each test shoould be
|
4
4
|
# responsible for setting up the logger
|
5
|
-
logger = ::Logger.new(STDOUT
|
5
|
+
logger = ::Logger.new(nil) # change to STDOUT to see rails logs
|
6
6
|
Rails.logger = logger
|
7
7
|
|
8
8
|
class RailsApp < Rails::Application
|
@@ -39,7 +39,7 @@ describe Timber::Probes::RailsRackLogger do
|
|
39
39
|
allow_any_instance_of(::Rails::Rack::Logger).to receive(:logger).and_return(logger)
|
40
40
|
dispatch_rails_request("/rails_rack_logger")
|
41
41
|
expect(io.string).to start_with("Started GET \"/rails_rack_logger\" for 123.456.789.10 @metadata {\"level\":\"info\",\"dt\":\"2016-09-01T12:00:00.000000Z\"")
|
42
|
-
expect(io.string).to include("\"event\":{\"server_side_app\":{\"http_server_request\":{\"host\":\"example.org\",\"method\":\"GET\",\"path\":\"/rails_rack_logger\",\"port\":80,\"headers\":{\"remote_addr\":\"123.456.789.10\",\"request_id\":\"unique-request-id-1234\"}}}")
|
42
|
+
expect(io.string).to include("\"event\":{\"server_side_app\":{\"http_server_request\":{\"host\":\"example.org\",\"method\":\"GET\",\"path\":\"/rails_rack_logger\",\"port\":80,\"headers\":{\"remote_addr\":\"123.456.789.10\",\"request_id\":\"unique-request-id-1234\",\"scheme\":\"http\"}}}")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|