scout_apm 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +4 -0
- data/lib/scout_apm/agent_context.rb +1 -1
- data/lib/scout_apm/logger.rb +16 -8
- data/lib/scout_apm/version.rb +1 -1
- data/test/unit/logger_test.rb +67 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe3261e9eced978064607b53499cc6293be5a058
|
4
|
+
data.tar.gz: 6d676264b1b042a9cbe355e09353a861b7bcc8b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fd76e1a585a61ad5cf2e1ded0a6e83dd958697ef79ca6cd95cc4643a7d07844ef0da37096d1a8303ee8e6c1fc56b33ad5436e20548d289f8a7aeb144e916d74
|
7
|
+
data.tar.gz: 9fda0efefb37ef6707950e03d4fdd745299e3f3921cebd8e3f56680b9f635bfc7839719329fce8b32ac34d51447561b27d805749303337fb65b15448edf410e2
|
data/CHANGELOG.markdown
CHANGED
@@ -220,7 +220,7 @@ module ScoutApm
|
|
220
220
|
{
|
221
221
|
:log_level => config.value('log_level'),
|
222
222
|
:log_file_path => config.value('log_file_path'),
|
223
|
-
:stdout => config.value('log_stdout')
|
223
|
+
:stdout => config.value('log_stdout') || environment.platform_integration.log_to_stdout?,
|
224
224
|
:stderr => config.value('log_stderr'),
|
225
225
|
:logger_class => config.value('log_class'),
|
226
226
|
}
|
data/lib/scout_apm/logger.rb
CHANGED
@@ -40,7 +40,11 @@ module ScoutApm
|
|
40
40
|
def fatal(*args, &block); @logger.fatal(*args, &block); end
|
41
41
|
|
42
42
|
def log_level=(level)
|
43
|
-
@logger.level = level
|
43
|
+
@logger.level = log_level_from_opts(level)
|
44
|
+
end
|
45
|
+
|
46
|
+
def log_level
|
47
|
+
@logger.level
|
44
48
|
end
|
45
49
|
|
46
50
|
def log_file_path
|
@@ -48,11 +52,11 @@ module ScoutApm
|
|
48
52
|
end
|
49
53
|
|
50
54
|
def stdout?
|
51
|
-
@opts[:stdout] || @opts[:log_file_path] == "STDOUT"
|
55
|
+
@opts[:stdout] || (@opts[:log_file_path] || "").upcase == "STDOUT"
|
52
56
|
end
|
53
57
|
|
54
58
|
def stderr?
|
55
|
-
@opts[:stderr] || @opts[:log_file_path] == "STDERR"
|
59
|
+
@opts[:stderr] || (@opts[:log_file_path] || "").upcase == "STDERR"
|
56
60
|
end
|
57
61
|
|
58
62
|
private
|
@@ -86,13 +90,16 @@ module ScoutApm
|
|
86
90
|
end
|
87
91
|
end
|
88
92
|
|
89
|
-
def log_level_from_opts
|
90
|
-
|
93
|
+
def log_level_from_opts(explicit=nil)
|
94
|
+
candidate = explicit || (@opts[:log_level] || "").downcase
|
95
|
+
|
96
|
+
case candidate
|
91
97
|
when "debug" then ::Logger::DEBUG
|
92
98
|
when "info" then ::Logger::INFO
|
93
99
|
when "warn" then ::Logger::WARN
|
94
100
|
when "error" then ::Logger::ERROR
|
95
101
|
when "fatal" then ::Logger::FATAL
|
102
|
+
when ::Logger::DEBUG, ::Logger::INFO, ::Logger::WARN, ::Logger::ERROR, ::Logger::FATAL then candidate
|
96
103
|
else ::Logger::INFO
|
97
104
|
end
|
98
105
|
end
|
@@ -116,11 +123,12 @@ module ScoutApm
|
|
116
123
|
# Check if this path is ok for a log file.
|
117
124
|
# Does it exist?
|
118
125
|
# Is it writable?
|
119
|
-
# XXX: Implement
|
120
126
|
def validate_path(candidate)
|
121
|
-
|
122
|
-
end
|
127
|
+
return false if candidate.nil?
|
123
128
|
|
129
|
+
directory = File.dirname(candidate)
|
130
|
+
File.writable?(directory)
|
131
|
+
end
|
124
132
|
|
125
133
|
class DefaultFormatter < ::Logger::Formatter
|
126
134
|
def call(severity, time, progname, msg)
|
data/lib/scout_apm/version.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'scout_apm/logger'
|
4
|
+
|
5
|
+
class LoggerTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@env_root = Pathname.new(File.dirname(__FILE__)) + "../../"
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_detect_stdout
|
11
|
+
logger = ScoutApm::Logger.new("", { :log_file_path => "STDOUT"})
|
12
|
+
assert logger.stdout?
|
13
|
+
assert_equal STDOUT, logger.log_destination
|
14
|
+
|
15
|
+
# and lowercase
|
16
|
+
logger = ScoutApm::Logger.new("", { :log_file_path => "stdout"})
|
17
|
+
assert logger.stdout?
|
18
|
+
assert_equal STDOUT, logger.log_destination
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_force_stdout
|
22
|
+
logger = ScoutApm::Logger.new("", { :stdout => true })
|
23
|
+
assert logger.stdout?
|
24
|
+
assert_equal STDOUT, logger.log_destination
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_pick_log_file_with_no_options
|
28
|
+
logger = ScoutApm::Logger.new(@env_root, { })
|
29
|
+
assert_equal (@env_root + "log" + "scout_apm.log").to_s, logger.log_destination
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_pick_log_file_with_different_dir
|
33
|
+
logger = ScoutApm::Logger.new(@env_root, { :log_file_path => "/tmp" })
|
34
|
+
assert_equal "/tmp/scout_apm.log", logger.log_destination
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_pick_log_file_invalid_dir
|
38
|
+
logger = ScoutApm::Logger.new(@env_root, { :log_file_path => "/not_a_real_dir" })
|
39
|
+
assert_equal STDOUT, logger.log_destination
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_pick_log_dir_not_writable
|
43
|
+
Dir.mktmpdir { |dir|
|
44
|
+
# An unwritable dir
|
45
|
+
FileUtils.chmod(0000, dir)
|
46
|
+
logger = ScoutApm::Logger.new(@env_root, { :log_file_path => dir })
|
47
|
+
assert_equal STDOUT, logger.log_destination
|
48
|
+
|
49
|
+
# so it can be deleted
|
50
|
+
FileUtils.chmod(0700, dir)
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_set_log_level
|
55
|
+
logger = ScoutApm::Logger.new(@env_root, { :log_level => "debug" })
|
56
|
+
assert_equal ::Logger::DEBUG, logger.log_level
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_set_log_level_after
|
60
|
+
logger = ScoutApm::Logger.new(@env_root, { :log_level => "debug" })
|
61
|
+
logger.log_level = "info"
|
62
|
+
assert_equal ::Logger::INFO, logger.log_level
|
63
|
+
|
64
|
+
logger.log_level = ::Logger::ERROR
|
65
|
+
assert_equal ::Logger::ERROR, logger.log_level
|
66
|
+
end
|
67
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout_apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Haynes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-01-
|
12
|
+
date: 2018-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -329,6 +329,7 @@ files:
|
|
329
329
|
- test/unit/layer_converters/metric_converter_test.rb
|
330
330
|
- test/unit/layer_converters/stubs.rb
|
331
331
|
- test/unit/limited_layer_test.rb
|
332
|
+
- test/unit/logger_test.rb
|
332
333
|
- test/unit/metric_set_test.rb
|
333
334
|
- test/unit/remote/test_message.rb
|
334
335
|
- test/unit/remote/test_router.rb
|
@@ -392,6 +393,7 @@ test_files:
|
|
392
393
|
- test/unit/layer_converters/metric_converter_test.rb
|
393
394
|
- test/unit/layer_converters/stubs.rb
|
394
395
|
- test/unit/limited_layer_test.rb
|
396
|
+
- test/unit/logger_test.rb
|
395
397
|
- test/unit/metric_set_test.rb
|
396
398
|
- test/unit/remote/test_message.rb
|
397
399
|
- test/unit/remote/test_router.rb
|