scout_apm_logging 0.0.7 → 0.0.8
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 +2 -0
- data/lib/scout_apm/logging/loggers/patches/tagged_logging.rb +14 -5
- data/lib/scout_apm/logging/loggers/proxy.rb +3 -3
- data/lib/scout_apm/logging/loggers/swaps/rails.rb +9 -1
- data/lib/scout_apm/logging/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b613ee5835fad514e57720ba9349bb90bc2eea19821891998655353d50447f3c
|
4
|
+
data.tar.gz: 29a0dda4469c4a4a2465816cc3cacfd332ae545af37f0b694c7aa3b6afb83ca6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 991c4af38d8027255b65a0e1225f0b3f295a3f6e76f2dbcb46a13b91644420b684f8c9ab343eb04708ed3dc499a46e38ea1ee8b2924e78361ea469a033d63d22
|
7
|
+
data.tar.gz: 667b91726ad60e9415d90db45fcef50f73f317308d42d1b17686bb1ae2de791ba75903e4bd5d9fbbcbe7009809b187fc468d6ebf18945edc5c6fa2f6e637b674
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.0.8
|
2
|
+
* Fix internal method names for proxy logger to prevent accidental overriding.
|
3
|
+
* Re-broadcast to console in development for the proxy logger.
|
4
|
+
* Fix tags not being removed when yielded contents throw an exception.
|
5
|
+
* Fix missing return statement, where tagged logging patches were being added to unintended loggers.
|
6
|
+
|
1
7
|
## 0.0.7
|
2
8
|
* Fix determined logger level comparison
|
3
9
|
|
@@ -3,7 +3,9 @@
|
|
3
3
|
module ScoutApm
|
4
4
|
module Logging
|
5
5
|
module Loggers
|
6
|
+
# The actual instance of the logger.
|
6
7
|
class FileLogger < ::Logger
|
8
|
+
include ::ActiveSupport::LoggerSilence if const_defined?('::ActiveSupport::LoggerSilence')
|
7
9
|
end
|
8
10
|
|
9
11
|
# The newly created logger which we can configure, and will log to a filepath.
|
@@ -11,8 +11,8 @@ module ScoutApm
|
|
11
11
|
# Patches TaggedLogging to work with our loggers.
|
12
12
|
module TaggedLogging
|
13
13
|
def tagged(*tags) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
14
|
-
super(*tags) unless (self == ::Rails.logger && is_a?(ScoutApm::Logging::Loggers::Proxy)) ||
|
15
|
-
|
14
|
+
return super(*tags) unless (self == ::Rails.logger && is_a?(ScoutApm::Logging::Loggers::Proxy)) ||
|
15
|
+
(::Rails.logger.respond_to?(:broadcasts) && ::Rails.logger.broadcasts.include?(self))
|
16
16
|
|
17
17
|
if is_a?(ScoutApm::Logging::Loggers::Proxy)
|
18
18
|
if block_given?
|
@@ -20,8 +20,13 @@ module ScoutApm
|
|
20
20
|
loggers = @loggers[1..]
|
21
21
|
pushed_counts = extend_and_push_tags(loggers, *tags)
|
22
22
|
|
23
|
-
|
23
|
+
begin
|
24
|
+
formatter.tagged(*tags) { yield self }.tap do
|
25
|
+
logger_pop_tags(loggers, pushed_counts)
|
26
|
+
end
|
27
|
+
rescue StandardError => e
|
24
28
|
logger_pop_tags(loggers, pushed_counts)
|
29
|
+
raise e
|
25
30
|
end
|
26
31
|
else
|
27
32
|
loggers = instance_variable_get(:@loggers)
|
@@ -36,9 +41,13 @@ module ScoutApm
|
|
36
41
|
# We skip the first logger to prevent double tagging when calling formatter.tagged
|
37
42
|
loggers = ::Rails.logger.broadcasts[1..]
|
38
43
|
pushed_counts = extend_and_push_tags(loggers, *tags)
|
39
|
-
|
40
|
-
|
44
|
+
begin
|
45
|
+
formatter.tagged(*tags) { yield self }.tap do
|
46
|
+
logger_pop_tags(loggers, pushed_counts)
|
47
|
+
end
|
48
|
+
rescue StandardError => e
|
41
49
|
logger_pop_tags(loggers, pushed_counts)
|
50
|
+
raise e
|
42
51
|
end
|
43
52
|
else
|
44
53
|
broadcasts = ::Rails.logger.broadcasts
|
@@ -7,7 +7,7 @@ module ScoutApm
|
|
7
7
|
class Proxy
|
8
8
|
def self.create_with_loggers(*loggers)
|
9
9
|
new.tap do |proxy_logger|
|
10
|
-
loggers.each { |logger| proxy_logger.
|
10
|
+
loggers.each { |logger| proxy_logger.add_scout_loggers(logger) }
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -15,11 +15,11 @@ module ScoutApm
|
|
15
15
|
@loggers = []
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def add_scout_loggers(logger)
|
19
19
|
@loggers << logger
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def remove_scout_loggers(logger)
|
23
23
|
@loggers.reject! { |inst_log| inst_log == logger }
|
24
24
|
|
25
25
|
@loggers
|
@@ -38,7 +38,7 @@ module ScoutApm
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# Eseentially creates the original logger.
|
41
|
-
def original_logger
|
41
|
+
def original_logger # rubocop:disable Metrics/AbcSize
|
42
42
|
# We can use the previous logdev. log_device will continuously call write
|
43
43
|
# through the devices until the logdev (@dev) is an IO device other than logdev:
|
44
44
|
# https://github.com/ruby/ruby/blob/master/lib/logger/log_device.rb#L42
|
@@ -48,6 +48,14 @@ module ScoutApm
|
|
48
48
|
::Logger.new(original_logdevice).tap do |logger|
|
49
49
|
logger.level = log_instance.level
|
50
50
|
logger.formatter = log_instance.formatter
|
51
|
+
|
52
|
+
if ::Rails.env.development? && $stdout.tty? && $stderr.tty?
|
53
|
+
next if ActiveSupport::Logger.respond_to?(:logger_outputs_to?) && ActiveSupport::Logger.logger_outputs_to?(
|
54
|
+
logger, $stdout, $stderr
|
55
|
+
)
|
56
|
+
|
57
|
+
logger.extend(ActiveSupport::Logger.broadcast(ActiveSupport::Logger.new($stdout)))
|
58
|
+
end
|
51
59
|
end
|
52
60
|
end
|
53
61
|
|
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.8
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: scout_apm
|