scout_apm_logging 0.0.5 → 0.0.7

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: a74ddd478e8429ef76315b9bdb23557583719b0ed241f0fecb1c0a6658b4efe7
4
- data.tar.gz: 72bc063672bff254e893c196662c69cc06934297379e21ee3482e15974b4f465
3
+ metadata.gz: 820ef17ae470e00a8860d6cb25ba09fb908c5c1c2396a564144e8336be787c0f
4
+ data.tar.gz: 3338d6fbdc74aa519db27e0017b23af3ede6f6bf7a1e3df4c10ca798e6bc6331
5
5
  SHA512:
6
- metadata.gz: 4f5ba120cff4d9087ce213736477eebb687159b126f415bf7e6ea2c3ddbf7b6058aa48b605f91031d4883af1b20019010a4f01ee6871b1fda79b5ff02cf29111
7
- data.tar.gz: f029117cdc4d4b83d26dd5cbb67a9ac7f64fac72c67763d97bb6a712b3f566a0d9661a463c6f563b86aa18369e69188f6251e3c791035e6c737bc6155e5c2ae8
6
+ metadata.gz: 2e2e011988efb53ed021f0003efab939181af9df79f5ac7b90eea773c0cbf87641f410ea34b4904022bce5ab37f310287e4a04293bee53c66d9d16d988b0aa20
7
+ data.tar.gz: '086fd228d639e53c693e05d9cd43f6200cd38f3df7dfa087e1f609fc51dec9b1621e51f06bf1c68eddaed19188c0772250b7249fa550e7a3f5d96a45519cd8f6'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.0.7
2
+ * Fix determined logger level comparison
3
+
4
+ ## 0.0.6
5
+ * Ensure logger level is set back to the original.
6
+
1
7
  ## 0.0.5
2
8
  * Remove `msg` attribute after it has been moved to the log body to prevent duplication.
3
9
 
@@ -25,7 +25,7 @@ module ScoutApm
25
25
 
26
26
  FileLogger.new(determine_file_path, LOG_AGE, log_size).tap do |logger|
27
27
  # Ruby's Logger handles a lot of the coercion itself.
28
- logger.level = context.config.value('logs_capture_level')
28
+ logger.level = determined_log_level
29
29
  # Add our custom formatter to the logger.
30
30
  logger.formatter = Formatter.new
31
31
  end
@@ -55,6 +55,22 @@ module ScoutApm
55
55
 
56
56
  private
57
57
 
58
+ # This makes the assumption that the logs we capture should be
59
+ # at least that of the original logger level, and not lower, but can be
60
+ # configured to be a higher cutoff.
61
+ def determined_log_level
62
+ capture_level = context.config.value('logs_capture_level')
63
+ capture_value = ::Logger::Severity.const_get(capture_level.upcase)
64
+
65
+ log_instance_value = if log_instance.level.is_a?(Integer)
66
+ log_instance.level
67
+ else
68
+ ::Logger::Severity.const_get(log_instance.level.to_s.upcase)
69
+ end
70
+
71
+ [capture_value, log_instance_value].max
72
+ end
73
+
58
74
  def find_log_destination(logdev)
59
75
  dev = try(logdev, :filename) || try(logdev, :dev)
60
76
  if dev.is_a?(String)
@@ -46,6 +46,7 @@ module ScoutApm
46
46
  original_logdevice = log_instance.instance_variable_get(:@logdev)
47
47
 
48
48
  ::Logger.new(original_logdevice).tap do |logger|
49
+ logger.level = log_instance.level
49
50
  logger.formatter = log_instance.formatter
50
51
  end
51
52
  end
@@ -41,6 +41,7 @@ module ScoutApm
41
41
  original_logdevice = log_instance.instance_variable_get(:@logdev)
42
42
 
43
43
  ::Logger.new(original_logdevice).tap do |logger|
44
+ logger.level = log_instance.level
44
45
  logger.formatter = log_instance.formatter
45
46
  end
46
47
  end
@@ -41,6 +41,7 @@ module ScoutApm
41
41
  original_logdevice = log_instance.instance_variable_get(:@logdev)
42
42
 
43
43
  ::Logger.new(original_logdevice).tap do |logger|
44
+ logger.level = log_instance.level
44
45
  logger.formatter = log_instance.formatter
45
46
  end
46
47
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ScoutApm
4
4
  module Logging
5
- VERSION = '0.0.5'
5
+ VERSION = '0.0.7'
6
6
  end
7
7
  end
@@ -47,6 +47,7 @@ describe ScoutApm::Logging do
47
47
  expect(messages.count('[TEST] Some log')).to eq(1)
48
48
  expect(messages.count('[YIELD] Yield Test')).to eq(1)
49
49
  expect(messages.count('Another Log')).to eq(1)
50
+ expect(messages.count('Should not be captured')).to eq(0)
50
51
 
51
52
  log_locations = lines.map { |item| item['log_location'] }.compact
52
53
 
data/spec/rails/app.rb CHANGED
@@ -12,6 +12,7 @@ Rails.logger = ActiveSupport::TaggedLogging.new(Logger.new($stdout))
12
12
 
13
13
  class App < ::Rails::Application
14
14
  config.eager_load = false
15
+ config.log_level = :info
15
16
 
16
17
  routes.append do
17
18
  root to: 'root#index'
@@ -24,6 +25,8 @@ class RootController < ActionController::Base
24
25
  Rails.logger.tagged('TEST').info('Some log')
25
26
  Rails.logger.tagged('YIELD') { logger.info('Yield Test') }
26
27
  Rails.logger.info('Another Log')
28
+ Rails.logger.debug('Should not be captured')
29
+
27
30
  render plain: Rails.version
28
31
  end
29
32
  end
@@ -19,6 +19,7 @@ describe ScoutApm::Logging::Loggers::Capture do
19
19
  ENV['SCOUT_MONITOR_INTERVAL'] = '10'
20
20
  ENV['SCOUT_MONITOR_INTERVAL_DELAY'] = '10'
21
21
  ENV['SCOUT_LOGS_MONITOR'] = 'true'
22
+ ENV['SCOUT_LOGS_CAPTURE_LEVEL'] = 'debug'
22
23
 
23
24
  output_from_log = capture_stdout do
24
25
  context = ScoutApm::Logging::Context.new
@@ -26,7 +27,10 @@ describe ScoutApm::Logging::Loggers::Capture do
26
27
  conf = ScoutApm::Logging::Config.with_file(context, conf_file)
27
28
  context.config = conf
28
29
 
29
- TestLoggerWrapper.logger = ScoutTestLogger.new($stdout)
30
+ test_logger = ScoutTestLogger.new($stdout)
31
+ test_logger.level = 'INFO'
32
+
33
+ TestLoggerWrapper.logger = test_logger
30
34
 
31
35
  capture = ScoutApm::Logging::Loggers::Capture.new(context)
32
36
  capture.setup!
@@ -34,16 +38,22 @@ describe ScoutApm::Logging::Loggers::Capture do
34
38
  expect(TestLoggerWrapper.logger.class).to eq(ScoutApm::Logging::Loggers::Proxy)
35
39
 
36
40
  TestLoggerWrapper.logger.info('TEST')
41
+ TestLoggerWrapper.logger.debug('SHOULD NOT CAPTURE')
37
42
 
38
43
  log_path = File.join(context.config.value('logs_proxy_log_dir'), 'test.log')
39
44
  content = File.read(log_path)
40
45
  expect(content).to include('TEST')
41
46
 
47
+ # Shouldn't capture. While the log_capture_level was set to debug,
48
+ # the original logger instance had a higher log level of info.
49
+ expect(content).not_to include('SHOULD NOT CAPTURE')
50
+
42
51
  state_file = File.read(context.config.value('monitor_state_file'))
43
52
  state_data = JSON.parse(state_file)
44
53
  expect(state_data['logs_monitored']).to eq([log_path])
45
54
  end
46
55
 
47
56
  expect(output_from_log).to include('TEST')
57
+ expect(output_from_log).not_to include('SHOULD NOT CAPTURE')
48
58
  end
49
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_apm_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scout APM
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-14 00:00:00.000000000 Z
11
+ date: 2024-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scout_apm
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubygems_version: 3.1.6
149
+ rubygems_version: 3.0.8
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: Ruby Logging Support