loggun 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/lib/loggun/config.rb +1 -1
- data/lib/loggun/helpers.rb +8 -8
- data/lib/loggun/version.rb +1 -1
- data/lib/loggun.rb +0 -1
- metadata +3 -5
- data/lib/loggun/http_helpers.rb +0 -48
- data/lib/loggun/modifiers/incoming_http.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3961b4ad035b4eea0df58d05ae9a8bd784797cf57df8fb8f054445d9f6275707
|
4
|
+
data.tar.gz: 5ff8b6d6beb6e1808418e8c4333146a52655fdb0731aabde77dd6077166c3633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c7729e96c2a98c400c182c88bf747981a165c433174bc2accf18db4265e4601920c1e499c20c4135762b3ebe12768b3041342f9c508f17378ce079592708be4
|
7
|
+
data.tar.gz: 51c77b99b976a7d766282125a8d8e92fd4ebbab0faef16e9fdb51ee9bfafb9fc33e5b091b20ddfd1f85762c7a9a88fafce05011973c33dd533e83ece5b5c1061
|
data/lib/loggun/config.rb
CHANGED
@@ -19,7 +19,7 @@ module Loggun
|
|
19
19
|
payload_keys: %i[sql name duration source]
|
20
20
|
}
|
21
21
|
}.freeze
|
22
|
-
DEFAULT_MODIFIERS = %i[rails active_record sidekiq clockwork
|
22
|
+
DEFAULT_MODIFIERS = %i[rails active_record sidekiq clockwork outgoing_http].freeze
|
23
23
|
|
24
24
|
attr_accessor(
|
25
25
|
:formatter,
|
data/lib/loggun/helpers.rb
CHANGED
@@ -150,6 +150,14 @@ module Loggun
|
|
150
150
|
type_as_arr.join('.')
|
151
151
|
end
|
152
152
|
|
153
|
+
def generate_log_transaction_id
|
154
|
+
if self.class.log_transaction_generator
|
155
|
+
return self.class.log_transaction_generator.call(self)
|
156
|
+
end
|
157
|
+
|
158
|
+
"#{SecureRandom.uuid[0..7]}_#{DateTime.now.strftime('%Q')}"
|
159
|
+
end
|
160
|
+
|
153
161
|
private
|
154
162
|
|
155
163
|
def normalize(type)
|
@@ -168,14 +176,6 @@ module Loggun
|
|
168
176
|
word
|
169
177
|
end
|
170
178
|
|
171
|
-
def generate_log_transaction_id
|
172
|
-
if self.class.log_transaction_generator
|
173
|
-
return self.class.log_transaction_generator.call
|
174
|
-
end
|
175
|
-
|
176
|
-
"#{SecureRandom.uuid[0..7]}_#{DateTime.now.strftime('%Q')}"
|
177
|
-
end
|
178
|
-
|
179
179
|
def logger
|
180
180
|
Loggun.logger
|
181
181
|
end
|
data/lib/loggun/version.rb
CHANGED
data/lib/loggun.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loggun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksandr Noskov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-04-
|
12
|
+
date: 2020-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -144,7 +144,6 @@ files:
|
|
144
144
|
- lib/loggun/config.rb
|
145
145
|
- lib/loggun/formatter.rb
|
146
146
|
- lib/loggun/helpers.rb
|
147
|
-
- lib/loggun/http_helpers.rb
|
148
147
|
- lib/loggun/modifiers.rb
|
149
148
|
- lib/loggun/modifiers/active_record.rb
|
150
149
|
- lib/loggun/modifiers/active_record/loggun_log_subscriber.rb
|
@@ -152,7 +151,6 @@ files:
|
|
152
151
|
- lib/loggun/modifiers/clockwork.rb
|
153
152
|
- lib/loggun/modifiers/clockwork/manager.rb
|
154
153
|
- lib/loggun/modifiers/clockwork/methods.rb
|
155
|
-
- lib/loggun/modifiers/incoming_http.rb
|
156
154
|
- lib/loggun/modifiers/outgoing_http.rb
|
157
155
|
- lib/loggun/modifiers/outgoing_http/block_logger.rb
|
158
156
|
- lib/loggun/modifiers/rails.rb
|
@@ -184,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
182
|
- !ruby/object:Gem::Version
|
185
183
|
version: '0'
|
186
184
|
requirements: []
|
187
|
-
rubygems_version: 3.0.
|
185
|
+
rubygems_version: 3.0.8
|
188
186
|
signing_key:
|
189
187
|
specification_version: 4
|
190
188
|
summary: Loggun
|
data/lib/loggun/http_helpers.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
module Loggun
|
2
|
-
module HttpHelpers
|
3
|
-
def self.included(klass)
|
4
|
-
klass.class_eval do
|
5
|
-
around_action :log_http_actions
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def log_http_actions
|
12
|
-
log_action :start
|
13
|
-
yield
|
14
|
-
log_action :response
|
15
|
-
rescue StandardError => e
|
16
|
-
log_action :response, fail: e
|
17
|
-
raise e
|
18
|
-
end
|
19
|
-
|
20
|
-
def log_action(action = :start, fail: nil)
|
21
|
-
api = request.path[/\w+/]
|
22
|
-
api_version = request.path[/v./]
|
23
|
-
type = "http_request.#{api}.#{action}"
|
24
|
-
data = { path: clean_pathname }
|
25
|
-
data[:api_version] = api_version if api_version
|
26
|
-
|
27
|
-
return Loggun.info type, data if action == :start
|
28
|
-
|
29
|
-
success = fail.nil? && instance_exec(&modifier_config.success_condition)
|
30
|
-
data[:success] = success
|
31
|
-
unless success
|
32
|
-
error = instance_exec(&modifier_config.error_info)
|
33
|
-
data[:error] = error if error
|
34
|
-
end
|
35
|
-
Loggun.info type, data
|
36
|
-
end
|
37
|
-
|
38
|
-
def clean_pathname
|
39
|
-
filtered_params = params.to_unsafe_h
|
40
|
-
filtered_params.delete('action')
|
41
|
-
request.path.gsub(/(#{filtered_params.values.join('|')})/, '').gsub(/\/api\/v./, '')
|
42
|
-
end
|
43
|
-
|
44
|
-
def modifier_config
|
45
|
-
Loggun::Config.instance.modifiers.incoming_http
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Loggun
|
2
|
-
module Modifiers
|
3
|
-
class IncomingHttp < Loggun::Modifiers::Base
|
4
|
-
def apply
|
5
|
-
return unless defined?(ActionPack)
|
6
|
-
|
7
|
-
controllers = Loggun::Config.instance.modifiers.incoming_http.controllers
|
8
|
-
controllers.each do |controller|
|
9
|
-
controller.constantize.class_eval do
|
10
|
-
include Loggun::HttpHelpers
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|