scout_apm_logging 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a55380380a6a30ccfe38b8a7b117e02e2aa8c3ffc09a679f194c0b93ed1f4062
4
- data.tar.gz: 0131aa6a8d6ed072553996fe58b5a4e3d1f1170e656dda3b8283bbad301f56e8
3
+ metadata.gz: b613ee5835fad514e57720ba9349bb90bc2eea19821891998655353d50447f3c
4
+ data.tar.gz: 29a0dda4469c4a4a2465816cc3cacfd332ae545af37f0b694c7aa3b6afb83ca6
5
5
  SHA512:
6
- metadata.gz: ddada293aa30a8c806e6ca1e7d318b5a2f412f990d2bd5e2eeb81e5ddd10d661a7362571c105d776f7c5adbeecd4d6adf788ba505c6d6b811f8824f30485550e
7
- data.tar.gz: 825aba7b09c6075bcb0230b18b582eb37daa08d0c2eff45c781c73efa8a058dbae4498e1702e14438320a3bf618aae52d738b81aabfa7e87b825a1efed827da8
6
+ metadata.gz: 991c4af38d8027255b65a0e1225f0b3f295a3f6e76f2dbcb46a13b91644420b684f8c9ab343eb04708ed3dc499a46e38ea1ee8b2924e78361ea469a033d63d22
7
+ data.tar.gz: 667b91726ad60e9415d90db45fcef50f73f317308d42d1b17686bb1ae2de791ba75903e4bd5d9fbbcbe7009809b187fc468d6ebf18945edc5c6fa2f6e637b674
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
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
+
7
+ ## 0.0.7
8
+ * Fix determined logger level comparison
9
+
1
10
  ## 0.0.6
2
11
  * Ensure logger level is set back to the original.
3
12
 
@@ -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.
@@ -62,7 +64,13 @@ module ScoutApm
62
64
  capture_level = context.config.value('logs_capture_level')
63
65
  capture_value = ::Logger::Severity.const_get(capture_level.upcase)
64
66
 
65
- [capture_value, log_instance.level].max
67
+ log_instance_value = if log_instance.level.is_a?(Integer)
68
+ log_instance.level
69
+ else
70
+ ::Logger::Severity.const_get(log_instance.level.to_s.upcase)
71
+ end
72
+
73
+ [capture_value, log_instance_value].max
66
74
  end
67
75
 
68
76
  def find_log_destination(logdev)
@@ -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
- (::Rails.logger.respond_to?(:broadcasts) && ::Rails.logger.broadcasts.include?(self))
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
- formatter.tagged(*tags) { yield self }.tap do
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
- formatter.tagged(*tags) { yield self }.tap do
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.add(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 add(logger)
18
+ def add_scout_loggers(logger)
19
19
  @loggers << logger
20
20
  end
21
21
 
22
- def remove(logger)
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ScoutApm
4
4
  module Logging
5
- VERSION = '0.0.6'
5
+ VERSION = '0.0.8'
6
6
  end
7
7
  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.6
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-20 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scout_apm