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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 820ef17ae470e00a8860d6cb25ba09fb908c5c1c2396a564144e8336be787c0f
4
- data.tar.gz: 3338d6fbdc74aa519db27e0017b23af3ede6f6bf7a1e3df4c10ca798e6bc6331
3
+ metadata.gz: b613ee5835fad514e57720ba9349bb90bc2eea19821891998655353d50447f3c
4
+ data.tar.gz: 29a0dda4469c4a4a2465816cc3cacfd332ae545af37f0b694c7aa3b6afb83ca6
5
5
  SHA512:
6
- metadata.gz: 2e2e011988efb53ed021f0003efab939181af9df79f5ac7b90eea773c0cbf87641f410ea34b4904022bce5ab37f310287e4a04293bee53c66d9d16d988b0aa20
7
- data.tar.gz: '086fd228d639e53c693e05d9cd43f6200cd38f3df7dfa087e1f609fc51dec9b1621e51f06bf1c68eddaed19188c0772250b7249fa550e7a3f5d96a45519cd8f6'
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
- (::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.7'
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.7
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