logjam_agent 0.38.4 → 0.39.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: 40a7fc87817d5d47fd6ec90066a0f383436cb25f3f50ee835c0372c2a7f895e2
4
- data.tar.gz: c5a89ddd87c4cc14191d9c69a16c3a0a91790ef8cbc513e35635b30f4a0a2c93
3
+ metadata.gz: 3d7b4025afcfb74c8ddface95761561c9afe00438b1efde33007d895c3082ebd
4
+ data.tar.gz: cd945e945bb82cef9d7021661224abe63ac63d655ae7f4c00523df545c9d1dd0
5
5
  SHA512:
6
- metadata.gz: 239cf4fda9b20bf22e65d5d7454f642f453cf34b4e5f4adcade67d7dae2233d6e596c35f70fbd9a9f4c68cf4f2e847a80a7f310002719d5f9a9852633f8cfe95
7
- data.tar.gz: d376a763eee26ec914c930afeb9379119c2f4a6b03e28aa45d1ff8110f5119f4974dc899054f952d647141db84f70e37620312ef29887b00ea3eb2bffe284723
6
+ metadata.gz: f926c57ee8e5498c626db610c9191f38fbdc851753e2aa19772ce641d7e6cab4300941bec45ee810ac186a991ea094d1d0aee6c803b33cb8937bf7595f4a3d9d
7
+ data.tar.gz: 98c2af2e48e1fe938472f1f1392dbe74e5b20f98c93629ba482e3adaa3b362ffc7ec7201782e4005a015618431e970c97994696e6e8ba5c89947c99e019ff68c
@@ -13,13 +13,16 @@ class LogjamAgent::ConsoleFormatter < Logger::Formatter
13
13
  end
14
14
  end
15
15
 
16
- class ActiveSupport::Logger
17
- class << self
18
- alias_method :original_broadcast, :broadcast
19
- def broadcast(logger)
20
- logger.formatter = LogjamAgent::ConsoleFormatter.new
21
- logger.formatter.extend(ActiveSupport::TaggedLogging::Formatter)
22
- original_broadcast(logger)
16
+ if Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new("7.1.0")
17
+
18
+ class ActiveSupport::Logger
19
+ class << self
20
+ alias_method :original_broadcast, :broadcast
21
+ def broadcast(logger)
22
+ logger.formatter = LogjamAgent::ConsoleFormatter.new
23
+ logger.formatter.extend(ActiveSupport::TaggedLogging::Formatter)
24
+ original_broadcast(logger)
25
+ end
23
26
  end
24
27
  end
25
28
  end
@@ -123,7 +126,7 @@ module LogjamAgent
123
126
  message = LogjamAgent.json_encode_payload(message)
124
127
  else
125
128
  message = message.to_s
126
- if request && severity >= Logger::ERROR && (e = detect_logged_exception(message))
129
+ if request && severity >= LogjamAgent.exception_auto_detection_level && (e = detect_logged_exception(message))
127
130
  request.add_exception(e)
128
131
  end
129
132
  end
@@ -12,6 +12,7 @@ module LogjamAgent
12
12
  @asset_prefix = Rails.application.config.assets.prefix rescue "---"
13
13
  @ignore_asset_requests = LogjamAgent.ignore_asset_requests
14
14
  @ignored_request_urls = LogjamAgent.ignored_request_urls
15
+ @use_to_default_s = Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new("7.1.0")
15
16
  end
16
17
 
17
18
  def call(env)
@@ -123,7 +124,8 @@ module LogjamAgent
123
124
  logjam_fields.merge!(extract_request_info(request))
124
125
 
125
126
  LogjamAgent.logjam_only do
126
- info "Started #{request.request_method} \"#{path}\" for #{ip} at #{start_time.to_default_s}" unless logjam_request.ignored?(:asset)
127
+ started_at_str = @use_to_default_s ? start_time.to_default_s : start_time.to_s
128
+ info "Started #{request.request_method} \"#{path}\" for #{ip} at #{started_at_str}" unless logjam_request.ignored?(:asset)
127
129
  end
128
130
  if spoofed
129
131
  error spoofed
@@ -10,6 +10,7 @@ module ActionController #:nodoc:
10
10
  params = payload[:params].except(*INTERNAL_PARAMS)
11
11
  format = payload[:format]
12
12
  format = format.to_s.upcase if format.is_a?(Symbol)
13
+ format = "*/*" if format.nil?
13
14
 
14
15
  controller = payload[:controller]
15
16
  action = payload[:action]
@@ -33,6 +33,19 @@ module LogjamAgent
33
33
  )
34
34
  LogjamAgent.logger = logger
35
35
  end
36
+
37
+ if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("7.1.0")
38
+ unless Rails.logger.is_a?(ActiveSupport::BroadcastLogger)
39
+ broadcast_logger = ActiveSupport::BroadcastLogger.new(Rails.logger)
40
+ broadcast_logger.formatter = Rails.logger.formatter
41
+ Rails.logger = broadcast_logger
42
+ LogjamAgent.logger = logger
43
+ end
44
+
45
+ unless app.config.consider_all_requests_local
46
+ Rails.error.logger = Rails.logger
47
+ end
48
+ end
36
49
  end
37
50
 
38
51
  initializer "logjam_agent", :after => "time_bandits" do |app|
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.38.4"
2
+ VERSION = "0.39.0"
3
3
  end
data/lib/logjam_agent.rb CHANGED
@@ -167,6 +167,9 @@ module LogjamAgent
167
167
  true
168
168
  end
169
169
 
170
+ mattr_accessor :exception_auto_detection_level
171
+ self.exception_auto_detection_level = Logger::ERROR
172
+
170
173
  def self.auto_detect_exception(exception_class)
171
174
  # ignore Exception classes created with Class.new (timeout.rb, my old friend)
172
175
  if (class_name = exception_class.to_s) =~ /^[\w:]+$/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logjam_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.4
4
+ version: 0.39.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-22 00:00:00.000000000 Z
11
+ date: 2023-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubygems_version: 3.3.26
131
+ rubygems_version: 3.4.10
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Logjam client library to be used with logjam