loggun 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 756771ea707f7cbaafd88da80dc72afd4311702718de31a087711b258f68d47a
4
- data.tar.gz: b2a00e34692488e289888c9f3d7aa433fc30f66828a160762cf2fe80aa5ea46b
3
+ metadata.gz: 3961b4ad035b4eea0df58d05ae9a8bd784797cf57df8fb8f054445d9f6275707
4
+ data.tar.gz: 5ff8b6d6beb6e1808418e8c4333146a52655fdb0731aabde77dd6077166c3633
5
5
  SHA512:
6
- metadata.gz: c797ff8ce8de7a5e2da28b95c9e498c1f78b827e5596f0bf1923fe87a3c5376fa5eef46c9169208225c262dc58bc846f05f4d5eefaa11ef8bd75c7e76f7ea2ee
7
- data.tar.gz: 94d4d7bc950a938e82ab17b76fd4e387a169b90f16adeae8199958876847905d28ce698ee47ef4fc17d34102c3e619796cc9e8e03b27dc67b55f36ec34af5f6b
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 incoming_http outgoing_http].freeze
22
+ DEFAULT_MODIFIERS = %i[rails active_record sidekiq clockwork outgoing_http].freeze
23
23
 
24
24
  attr_accessor(
25
25
  :formatter,
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Loggun
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
data/lib/loggun.rb CHANGED
@@ -5,7 +5,6 @@ require 'loggun/config'
5
5
  require 'loggun/modifiers'
6
6
  require 'loggun/modifiers/base'
7
7
  require 'loggun/helpers'
8
- require 'loggun/http_helpers'
9
8
  require 'logger'
10
9
 
11
10
  module Loggun
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.2.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-13 00:00:00.000000000 Z
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.6
185
+ rubygems_version: 3.0.8
188
186
  signing_key:
189
187
  specification_version: 4
190
188
  summary: Loggun
@@ -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