scout_apm_logging 0.0.3 → 0.0.4

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: bb4dc1a11fe63b4c983636958676d8ca7e76bb04c5281bdabd272373deaf83e5
4
- data.tar.gz: 70809502cbbfb93a9cc73e26329f4e52b57008f51f9e34b3769fdfb17b2d46f4
3
+ metadata.gz: 7a99a84cd9f8dd023b8717c81e5d80b17c99f5afb8c7e7edb6152193ef7fecdf
4
+ data.tar.gz: b9d2e44b40adcb5f9acc13f6ef6d2176e79ed6b056f6e6d1e8f9f0359857ebf6
5
5
  SHA512:
6
- metadata.gz: b3a17d497a14d952294dd23ce5eac8605f7cee5da807ba53cc312acafbe314c33a303d75d97ac828f3ea1aba40e733da1104aa655866121e7f3c149afc9935cb
7
- data.tar.gz: 3515ffc8593bc564318859e0fb7340f82c2c066509a82411091b8e5e21bb4abcb223e1318d83b76a12ac11986db22bf4abaec5f511d6c07bdcaa5cc32742b7fd
6
+ metadata.gz: 1f73329ada6fde049cf1ffe18ad2d43c0fa09158cffcc10e51c58f897d9cd40f1aa2636ee645e2b26d7a36204e082ca318c5281e8e32759aaac2b685a4ff5f32
7
+ data.tar.gz: 664471524c4802ad23cfeee6299a56259d07e7a9a9d2fb241393202b4116946052f695982ada22c3060a39fca25f351ce6a90487e329283bc264749e6ee56738
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.0.4
2
+ * Fix memoizing of log attributes, which could lead to persistent attributes.
3
+
1
4
  ## 0.0.3
2
5
  * **Feature**: Add support for TaggedLogging.
3
6
  * Add ability to customize file logger size. Increase default size to 10MiB.
@@ -12,12 +12,15 @@ module ScoutApm
12
12
  class Formatter < ::Logger::Formatter
13
13
  DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%LZ'
14
14
 
15
- def call(severity, time, progname, msg) # rubocop:disable Metrics/AbcSize
16
- attributes_to_log[:severity] = severity
17
- attributes_to_log[:time] = format_datetime(time)
15
+ def call(severity, time, progname, msg)
16
+ attributes_to_log = {
17
+ severity: severity,
18
+ time: format_datetime(time),
19
+ pid: Process.pid.to_s,
20
+ msg: msg2str(msg)
21
+ }
22
+
18
23
  attributes_to_log[:progname] = progname if progname
19
- attributes_to_log[:pid] = Process.pid.to_s
20
- attributes_to_log[:msg] = msg2str(msg)
21
24
  attributes_to_log['service.name'] = service_name
22
25
 
23
26
  attributes_to_log.merge!(scout_layer)
@@ -30,10 +33,6 @@ module ScoutApm
30
33
 
31
34
  private
32
35
 
33
- def attributes_to_log
34
- @attributes_to_log ||= {}
35
- end
36
-
37
36
  def format_datetime(time)
38
37
  time.utc.strftime(DATETIME_FORMAT)
39
38
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ScoutApm
4
4
  module Logging
5
- VERSION = '0.0.3'
5
+ VERSION = '0.0.4'
6
6
  end
7
7
  end
@@ -48,6 +48,11 @@ describe ScoutApm::Logging do
48
48
  expect(messages.count('[YIELD] Yield Test')).to eq(1)
49
49
  expect(messages.count('Another Log')).to eq(1)
50
50
 
51
+ log_locations = lines.map { |item| item['log_location'] }.compact
52
+
53
+ # Verify that log attributes aren't persisted
54
+ expect(log_locations.size).to eq(1)
55
+
51
56
  # Kill the rails process. We use kill as using any other signal throws a long log line.
52
57
  Process.kill('KILL', rails_pid)
53
58
  # Kill the process and ensure PID file clean up
data/spec/rails/app.rb CHANGED
@@ -20,6 +20,7 @@ end
20
20
 
21
21
  class RootController < ActionController::Base
22
22
  def index
23
+ Rails.logger.warn('Add location log attributes')
23
24
  Rails.logger.tagged('TEST').info('Some log')
24
25
  Rails.logger.tagged('YIELD') { logger.info('Yield Test') }
25
26
  Rails.logger.info('Another Log')
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.3
4
+ version: 0.0.4
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-08 00:00:00.000000000 Z
11
+ date: 2024-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scout_apm