applicaster-logger 0.5.8 → 0.6.0
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.
data/lib/applicaster-logger.rb
CHANGED
data/lib/applicaster/logger.rb
CHANGED
@@ -16,7 +16,7 @@ module Applicaster
|
|
16
16
|
end
|
17
17
|
|
18
18
|
app.middleware.insert_after ActionDispatch::RequestId,
|
19
|
-
Applicaster::Rack::
|
19
|
+
Applicaster::Rack::RequestData
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.setup_logger(app)
|
@@ -53,17 +53,17 @@ module Applicaster
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def self.
|
57
|
-
old, Thread.current[:
|
58
|
-
Thread.current[:
|
56
|
+
def self.with_thread_data(data)
|
57
|
+
old, Thread.current[:logger_thread_data] =
|
58
|
+
Thread.current[:logger_thread_data], data
|
59
59
|
|
60
60
|
yield
|
61
61
|
ensure
|
62
|
-
Thread.current[:
|
62
|
+
Thread.current[:logger_thread_data] = old
|
63
63
|
end
|
64
64
|
|
65
|
-
def self.
|
66
|
-
Thread.current[:
|
65
|
+
def self.current_thread_data
|
66
|
+
Thread.current[:logger_thread_data] || {}
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -42,8 +42,8 @@ module Applicaster
|
|
42
42
|
event[:environment] ||= Rails.env
|
43
43
|
event[:token] = ENV['LOGZIO_TOKEN'] if ENV['LOGZIO_TOKEN']
|
44
44
|
|
45
|
-
|
46
|
-
event[
|
45
|
+
Applicaster::Logger.current_thread_data.each do |field, value|
|
46
|
+
event[field] = value
|
47
47
|
end
|
48
48
|
|
49
49
|
default_fields.each do |field, value|
|
@@ -1,17 +1,23 @@
|
|
1
1
|
module Applicaster
|
2
2
|
module Rack
|
3
|
-
class
|
3
|
+
class RequestData
|
4
4
|
def initialize(app)
|
5
5
|
@app = app
|
6
6
|
end
|
7
7
|
|
8
8
|
def call(env)
|
9
|
-
|
10
|
-
|
11
|
-
Applicaster::Logger.with_request_uuid(request.uuid) do
|
9
|
+
Applicaster::Logger.with_thread_data(request_data(env)) do
|
12
10
|
@app.call(env)
|
13
11
|
end
|
14
12
|
end
|
13
|
+
|
14
|
+
def request_data(env)
|
15
|
+
request = ActionDispatch::Request.new(env)
|
16
|
+
{
|
17
|
+
request_uuid: request.uuid,
|
18
|
+
remote_ip: request.remote_ip,
|
19
|
+
}
|
20
|
+
end
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: applicaster-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-07-
|
12
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: logstash-logger
|
@@ -93,7 +93,7 @@ files:
|
|
93
93
|
- lib/applicaster/logger/formatter.rb
|
94
94
|
- lib/applicaster/logger/railtie.rb
|
95
95
|
- lib/applicaster/logger/version.rb
|
96
|
-
- lib/applicaster/rack/
|
96
|
+
- lib/applicaster/rack/request_data.rb
|
97
97
|
- lib/applicaster/sidekiq/middleware.rb
|
98
98
|
homepage: ''
|
99
99
|
licenses:
|
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
segments:
|
112
112
|
- 0
|
113
|
-
hash:
|
113
|
+
hash: 224925595209252311
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
none: false
|
116
116
|
requirements:
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
segments:
|
121
121
|
- 0
|
122
|
-
hash:
|
122
|
+
hash: 224925595209252311
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
125
|
rubygems_version: 1.8.23
|