scout_apm_logging 0.0.5 → 0.0.6

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: a55380380a6a30ccfe38b8a7b117e02e2aa8c3ffc09a679f194c0b93ed1f4062
4
+ data.tar.gz: 0131aa6a8d6ed072553996fe58b5a4e3d1f1170e656dda3b8283bbad301f56e8
5
5
  SHA512:
6
- metadata.gz: 4f5ba120cff4d9087ce213736477eebb687159b126f415bf7e6ea2c3ddbf7b6058aa48b605f91031d4883af1b20019010a4f01ee6871b1fda79b5ff02cf29111
7
- data.tar.gz: f029117cdc4d4b83d26dd5cbb67a9ac7f64fac72c67763d97bb6a712b3f566a0d9661a463c6f563b86aa18369e69188f6251e3c791035e6c737bc6155e5c2ae8
6
+ metadata.gz: ddada293aa30a8c806e6ca1e7d318b5a2f412f990d2bd5e2eeb81e5ddd10d661a7362571c105d776f7c5adbeecd4d6adf788ba505c6d6b811f8824f30485550e
7
+ data.tar.gz: 825aba7b09c6075bcb0230b18b582eb37daa08d0c2eff45c781c73efa8a058dbae4498e1702e14438320a3bf618aae52d738b81aabfa7e87b825a1efed827da8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.0.6
2
+ * Ensure logger level is set back to the original.
3
+
1
4
  ## 0.0.5
2
5
  * Remove `msg` attribute after it has been moved to the log body to prevent duplication.
3
6
 
@@ -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,16 @@ 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
+ [capture_value, log_instance.level].max
66
+ end
67
+
58
68
  def find_log_destination(logdev)
59
69
  dev = try(logdev, :filename) || try(logdev, :dev)
60
70
  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.6'
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.6
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