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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/scout_apm/logging/loggers/logger.rb +17 -1
- data/lib/scout_apm/logging/loggers/swaps/rails.rb +1 -0
- data/lib/scout_apm/logging/loggers/swaps/scout.rb +1 -0
- data/lib/scout_apm/logging/loggers/swaps/sidekiq.rb +1 -0
- data/lib/scout_apm/logging/version.rb +1 -1
- data/spec/integration/rails/lifecycle_spec.rb +1 -0
- data/spec/rails/app.rb +3 -0
- data/spec/unit/loggers/capture_spec.rb +11 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 820ef17ae470e00a8860d6cb25ba09fb908c5c1c2396a564144e8336be787c0f
|
4
|
+
data.tar.gz: 3338d6fbdc74aa519db27e0017b23af3ede6f6bf7a1e3df4c10ca798e6bc6331
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e2e011988efb53ed021f0003efab939181af9df79f5ac7b90eea773c0cbf87641f410ea34b4904022bce5ab37f310287e4a04293bee53c66d9d16d988b0aa20
|
7
|
+
data.tar.gz: '086fd228d639e53c693e05d9cd43f6200cd38f3df7dfa087e1f609fc51dec9b1621e51f06bf1c68eddaed19188c0772250b7249fa550e7a3f5d96a45519cd8f6'
|
data/CHANGELOG.md
CHANGED
@@ -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 =
|
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)
|
@@ -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
|
-
|
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.
|
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-
|
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.
|
149
|
+
rubygems_version: 3.0.8
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Ruby Logging Support
|