lumberjack_rails 1.0.1 → 1.0.2
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 +4 -4
- data/.github/dependabot.yml +5 -3
- data/.github/workflows/continuous_integration.yml +12 -35
- data/.standard.yml +0 -3
- data/CHANGE_LOG.md +21 -0
- data/VERSION +1 -1
- data/lib/lumberjack/rails/action_controller_log_subscriber_extension.rb +2 -2
- data/lib/lumberjack/rails/apply_patches.rb +3 -3
- data/lib/lumberjack/rails/broadcast_logger_extension.rb +20 -18
- data/lib/lumberjack/rails/log_at_level.rb +9 -0
- data/lib/lumberjack/rails/railtie.rb +9 -4
- data/lib/lumberjack/rails/tagged_forked_logger.rb +30 -2
- data/lib/lumberjack/rails.rb +0 -1
- data/lumberjack_rails.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a3a13074830f25a5060ee4d39cb6dd8fa3796c11071f6b2612690b418c22aaf
|
|
4
|
+
data.tar.gz: e4716c659a0c73f9894e22cda0acb2048af45d91b0dfd5e7944475d2603733fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4332df5d1d72807b12e5037a3617fc2bf44fe82a42187f0b0205120fe39905297896eb158b134aff5bb62fb8d6b4cf9489034b393c58115208a7878acb4bfc6f
|
|
7
|
+
data.tar.gz: 636dc7aeb27053785c986ec699ce5ac7ec7eb5b456e0d71a26a2ab4561fdc530943161bfeae1a49f8306d2a4ed4956006b8f4a75396156b89451c1ac7c2ae45a
|
data/.github/dependabot.yml
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# Dependabot update strategy
|
|
2
1
|
version: 2
|
|
3
2
|
updates:
|
|
4
3
|
- package-ecosystem: bundler
|
|
@@ -6,7 +5,10 @@ updates:
|
|
|
6
5
|
schedule:
|
|
7
6
|
interval: weekly
|
|
8
7
|
allow:
|
|
9
|
-
# Automatically keep all runtime dependencies updated
|
|
10
8
|
- dependency-name: "*"
|
|
11
9
|
dependency-type: "production"
|
|
12
|
-
versioning-strategy:
|
|
10
|
+
versioning-strategy: increase-if-necessary
|
|
11
|
+
- package-ecosystem: github-actions
|
|
12
|
+
directory: "/"
|
|
13
|
+
schedule:
|
|
14
|
+
interval: weekly
|
|
@@ -10,12 +10,6 @@ on:
|
|
|
10
10
|
- actions-*
|
|
11
11
|
workflow_dispatch:
|
|
12
12
|
|
|
13
|
-
env:
|
|
14
|
-
BUNDLE_CLEAN: "true"
|
|
15
|
-
BUNDLE_PATH: vendor/bundle
|
|
16
|
-
BUNDLE_JOBS: 3
|
|
17
|
-
BUNDLE_RETRY: 3
|
|
18
|
-
|
|
19
13
|
jobs:
|
|
20
14
|
build:
|
|
21
15
|
name: build ruby-${{ matrix.ruby }} ${{ matrix.appraisal }}
|
|
@@ -38,33 +32,16 @@ jobs:
|
|
|
38
32
|
- ruby: "ruby"
|
|
39
33
|
appraisal: no_rails
|
|
40
34
|
steps:
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
- name: Checkout
|
|
36
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
37
|
+
with:
|
|
38
|
+
persist-credentials: false
|
|
39
|
+
- name: Ruby CI
|
|
40
|
+
uses: bdurand/github-actions/ruby-ci@v1.0.4
|
|
44
41
|
with:
|
|
45
|
-
ruby
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if: matrix.bundler != ''
|
|
52
|
-
run: |
|
|
53
|
-
gem uninstall bundler --all
|
|
54
|
-
gem install bundler --no-document --version ${{ matrix.bundler }}
|
|
55
|
-
- name: Set Appraisal bundle
|
|
56
|
-
if: matrix.appraisal != ''
|
|
57
|
-
run: |
|
|
58
|
-
echo "using gemfile gemfiles/${{ matrix.appraisal }}.gemfile"
|
|
59
|
-
bundle config set gemfile "gemfiles/${{ matrix.appraisal }}.gemfile"
|
|
60
|
-
- name: Install gems
|
|
61
|
-
run: |
|
|
62
|
-
bundle update
|
|
63
|
-
- name: Run Tests
|
|
64
|
-
run: bundle exec rake
|
|
65
|
-
- name: standardrb
|
|
66
|
-
if: matrix.standardrb == true
|
|
67
|
-
run: bundle exec standardrb
|
|
68
|
-
- name: yard
|
|
69
|
-
if: matrix.yard == true
|
|
70
|
-
run: bundle exec yard --fail-on-warning
|
|
42
|
+
ruby: ${{ matrix.ruby }}
|
|
43
|
+
appraisal: ${{ matrix.appraisal }}
|
|
44
|
+
bundler: ${{ matrix.bundler }}
|
|
45
|
+
standardrb: ${{ matrix.standardrb }}
|
|
46
|
+
yard: ${{ matrix.yard }}
|
|
47
|
+
frozen_strings: ${{ matrix.frozen_strings }}
|
data/.standard.yml
CHANGED
data/CHANGE_LOG.md
CHANGED
|
@@ -4,6 +4,27 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## 1.0.2
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Bumped the minimum lumberjack version dependency to 2.1.
|
|
12
|
+
|
|
13
|
+
### Removed
|
|
14
|
+
|
|
15
|
+
- Removed `untagged` and `set_progname` from `ActiveSupport::BroadcastLogger`. Both methods were removed from `Lumberjack::Logger` in lumberjack 2.1, so the broadcast versions no longer had anything to dispatch to. Use `clear_attributes` instead of `untagged` and `with_progname` instead of `set_progname`.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Fixed local log levels set with `silence` and `log_at` bleeding between unrelated loggers. ActiveSupport 8.1 sets the key used to store the local log level in the logger constructor, which Lumberjack loggers do not call, so all loggers were sharing a single local level per thread.
|
|
20
|
+
- Forked loggers now share the ActiveSupport local log level with their parent logger so that calling `silence` or `log_at` on the main logger applies to log subscriber loggers forked from it.
|
|
21
|
+
- `ActiveSupport::BroadcastLogger#local_level` now reads from the broadcasted loggers on ActiveSupport versions prior to 8.1 so that `silence` and `log_at` behave consistently across versions.
|
|
22
|
+
- `ActiveSupport::BroadcastLogger#add` now coerces the severity with `Lumberjack::Severity` so that Lumberjack-specific severities like `:trace` work and so that it does not depend on `Logger::Severity.coerce`, which only exists in logger gem 1.6 and later.
|
|
23
|
+
- `tagged` on a forked logger now executes the block even when the parent logger does not support tagged logging. Previously the block was silently skipped.
|
|
24
|
+
- Fixed typo in the Railtie that failed to exclude `config.lumberjack.request_attributes_proc` from the options passed to the logger constructor.
|
|
25
|
+
- The Railtie no longer mutates the `config.lumberjack.attributes` hash and no longer copies dynamic `config.log_tags` values (Symbols and Procs) as static logger attributes. Dynamic tags are evaluated per request by `Rails::Rack::Logger` and were being logged as literal values on entries outside of requests.
|
|
26
|
+
- `ActionController::LogSubscriber.add_process_log_attribute` now handles a static value of `false` correctly instead of storing `nil`.
|
|
27
|
+
|
|
7
28
|
## 1.0.1
|
|
8
29
|
|
|
9
30
|
### Changed
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.2
|
|
@@ -37,9 +37,9 @@ module Lumberjack::Rails
|
|
|
37
37
|
# @return [void]
|
|
38
38
|
def add_process_log_attribute(name, value = nil, &block)
|
|
39
39
|
raise ArgumentError.new("Must provide a value or a block") if value.nil? && block.nil?
|
|
40
|
-
raise ArgumentError.new("Cannot provide both a value and a block") if value && block
|
|
40
|
+
raise ArgumentError.new("Cannot provide both a value and a block") if !value.nil? && block
|
|
41
41
|
|
|
42
|
-
@lumberjack_process_log_attributes[name.to_s] =
|
|
42
|
+
@lumberjack_process_log_attributes[name.to_s] = block || value
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
# Add log attributes to be included in the process_action log entry. The block must
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
# backward compatibility with existing Rails logging patterns.
|
|
17
17
|
|
|
18
18
|
# Remove deprecated methods on Lumberjack::Logger that are implemented by ActiveSupport
|
|
19
|
-
Lumberjack::Logger.remove_method(:tagged) if Lumberjack::Logger.
|
|
20
|
-
Lumberjack::Logger.remove_method(:log_at) if Lumberjack::Logger.
|
|
21
|
-
Lumberjack::Logger.remove_method(:silence) if Lumberjack::Logger.
|
|
19
|
+
Lumberjack::Logger.remove_method(:tagged) if Lumberjack::Logger.method_defined?(:tagged)
|
|
20
|
+
Lumberjack::Logger.remove_method(:log_at) if Lumberjack::Logger.method_defined?(:log_at)
|
|
21
|
+
Lumberjack::Logger.remove_method(:silence) if Lumberjack::Logger.method_defined?(:silence)
|
|
22
22
|
|
|
23
23
|
# Add tagged logging support to the Lumberjack::EntryFormatter
|
|
24
24
|
Lumberjack::EntryFormatter.prepend(Lumberjack::Rails::TaggedLoggingFormatter)
|
|
@@ -100,7 +100,7 @@ module Lumberjack
|
|
|
100
100
|
# @yield optional block that returns the message
|
|
101
101
|
# @return [void]
|
|
102
102
|
def add(severity, message_or_progname_or_attributes = nil, progname_or_attributes = nil, &block)
|
|
103
|
-
severity =
|
|
103
|
+
severity = Lumberjack::Severity.coerce(severity)
|
|
104
104
|
dispatch_to_each(block) do |logger, one_time_block|
|
|
105
105
|
call_add_with_attributes_arg(logger, severity, message_or_progname_or_attributes, progname_or_attributes, &one_time_block)
|
|
106
106
|
end
|
|
@@ -117,6 +117,25 @@ module Lumberjack
|
|
|
117
117
|
log_at(level, &block)
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
+
# Get the local log level from the broadcasted loggers. ActiveSupport 8.1 added
|
|
121
|
+
# this method to BroadcastLogger; it is defined here so that silence and log_at
|
|
122
|
+
# work consistently on older versions of ActiveSupport as well.
|
|
123
|
+
#
|
|
124
|
+
# @return [Integer, nil] the local log level
|
|
125
|
+
def local_level
|
|
126
|
+
broadcasts.filter_map { |logger| logger.local_level if logger.respond_to?(:local_level) }.first
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Set the local log level on all broadcasted loggers that support it.
|
|
130
|
+
#
|
|
131
|
+
# @param level [Integer, Symbol, nil] the local log level
|
|
132
|
+
# @return [void]
|
|
133
|
+
def local_level=(level)
|
|
134
|
+
broadcasts.each do |logger|
|
|
135
|
+
logger.local_level = level if logger.respond_to?(:local_level=)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
120
139
|
# Tag log entries with the specified attributes.
|
|
121
140
|
#
|
|
122
141
|
# @param attributes [Hash] the attributes to tag with
|
|
@@ -160,14 +179,6 @@ module Lumberjack
|
|
|
160
179
|
dispatch_block_method(:clear_attributes, &block)
|
|
161
180
|
end
|
|
162
181
|
|
|
163
|
-
# Execute a block without any tags.
|
|
164
|
-
#
|
|
165
|
-
# @yield the block to execute without tags
|
|
166
|
-
# @return [Object] the result of the block execution
|
|
167
|
-
def untagged(&block)
|
|
168
|
-
dispatch_block_method(:untagged, &block)
|
|
169
|
-
end
|
|
170
|
-
|
|
171
182
|
# Set the progname temporarily for a block.
|
|
172
183
|
#
|
|
173
184
|
# @param value [String] the progname to set
|
|
@@ -177,15 +188,6 @@ module Lumberjack
|
|
|
177
188
|
dispatch_block_method(:with_progname, value, &block)
|
|
178
189
|
end
|
|
179
190
|
|
|
180
|
-
# Alias for with_progname for backward compatibility.
|
|
181
|
-
#
|
|
182
|
-
# @param value [String] the progname to set
|
|
183
|
-
# @yield the block to execute with the specified progname
|
|
184
|
-
# @return [Object] the result of the block execution
|
|
185
|
-
def set_progname(value, &block)
|
|
186
|
-
dispatch_block_method(:with_progname, value, &block)
|
|
187
|
-
end
|
|
188
|
-
|
|
189
191
|
# Create a forked logger from this broadcast logger.
|
|
190
192
|
#
|
|
191
193
|
# @param level [Symbol, Integer] optional log level for the forked logger
|
|
@@ -14,6 +14,15 @@ module Lumberjack
|
|
|
14
14
|
def level
|
|
15
15
|
local_level || super
|
|
16
16
|
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
# ActiveSupport::LoggerThreadSafeLevel#initialize sets this key, but Lumberjack
|
|
21
|
+
# loggers never call super in their constructors, so without this override every
|
|
22
|
+
# logger would share the nil key and local levels would bleed between loggers.
|
|
23
|
+
def local_level_key
|
|
24
|
+
@local_level_key ||= :"logger_thread_safe_level_#{object_id}"
|
|
25
|
+
end
|
|
17
26
|
end
|
|
18
27
|
end
|
|
19
28
|
end
|
|
@@ -77,10 +77,15 @@ class Lumberjack::Rails::Railtie < ::Rails::Railtie
|
|
|
77
77
|
level = config.lumberjack.level || config.log_level || :debug
|
|
78
78
|
|
|
79
79
|
# Set default attributes
|
|
80
|
-
attributes = config.lumberjack.attributes
|
|
80
|
+
attributes = config.lumberjack.attributes&.dup
|
|
81
81
|
if config.log_tags
|
|
82
|
-
|
|
83
|
-
attributes
|
|
82
|
+
# Symbol and Proc tags are evaluated per request by Rails::Rack::Logger, so only
|
|
83
|
+
# static tag values can be applied as default attributes on the logger itself.
|
|
84
|
+
static_tags = config.log_tags.reject { |tag| tag.is_a?(Symbol) || tag.respond_to?(:call) }
|
|
85
|
+
unless static_tags.empty?
|
|
86
|
+
attributes ||= {}
|
|
87
|
+
attributes["tags"] = static_tags
|
|
88
|
+
end
|
|
84
89
|
end
|
|
85
90
|
|
|
86
91
|
shift_age = config.lumberjack.shift_age || 0
|
|
@@ -97,7 +102,7 @@ class Lumberjack::Rails::Railtie < ::Rails::Railtie
|
|
|
97
102
|
:shift_size,
|
|
98
103
|
:log_rake_tasks,
|
|
99
104
|
:middleware,
|
|
100
|
-
:
|
|
105
|
+
:request_attributes_proc,
|
|
101
106
|
:silence_rack_request_started
|
|
102
107
|
)
|
|
103
108
|
|
|
@@ -5,16 +5,44 @@ module Lumberjack
|
|
|
5
5
|
# Extension for Lumberjack::ForkedLogger to support ActiveSupport tagged logging.
|
|
6
6
|
#
|
|
7
7
|
# This module adds tagged logging capabilities to forked loggers by
|
|
8
|
-
# delegating tagged calls to the parent logger when available.
|
|
8
|
+
# delegating tagged calls to the parent logger when available. It also
|
|
9
|
+
# shares the ActiveSupport local log level (used by silence and log_at)
|
|
10
|
+
# with the parent logger so that silencing the parent silences the fork.
|
|
9
11
|
module TaggedForkedLogger
|
|
10
12
|
# Execute a block with the specified tags if the parent logger supports tagging.
|
|
13
|
+
# If the parent logger does not support tagging, the block is still executed
|
|
14
|
+
# without any tags applied.
|
|
11
15
|
#
|
|
12
16
|
# @param tags [Array] the tags to apply during block execution
|
|
13
17
|
# @yield the block to execute with the specified tags
|
|
14
|
-
# @return [Object] the result of the block execution
|
|
18
|
+
# @return [Object] the result of the block execution
|
|
15
19
|
def tagged(*tags, &block)
|
|
16
20
|
if parent_logger.respond_to?(:tagged)
|
|
17
21
|
parent_logger.tagged(*tags, &block)
|
|
22
|
+
elsif block
|
|
23
|
+
block.call
|
|
24
|
+
else
|
|
25
|
+
self
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Get the local log level from the parent logger so that silence and log_at
|
|
30
|
+
# on the parent apply to log entries written through the forked logger.
|
|
31
|
+
#
|
|
32
|
+
# @return [Integer, nil] the local log level
|
|
33
|
+
def local_level
|
|
34
|
+
parent_logger.respond_to?(:local_level) ? parent_logger.local_level : super
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Set the local log level on the parent logger.
|
|
38
|
+
#
|
|
39
|
+
# @param value [Integer, Symbol, nil] the local log level
|
|
40
|
+
# @return [void]
|
|
41
|
+
def local_level=(value)
|
|
42
|
+
if parent_logger.respond_to?(:local_level=)
|
|
43
|
+
parent_logger.local_level = value
|
|
44
|
+
else
|
|
45
|
+
super
|
|
18
46
|
end
|
|
19
47
|
end
|
|
20
48
|
end
|
data/lib/lumberjack/rails.rb
CHANGED
data/lumberjack_rails.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lumberjack_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian Durand
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: lumberjack
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 2.
|
|
18
|
+
version: '2.1'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 2.
|
|
25
|
+
version: '2.1'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: activesupport
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
91
91
|
- !ruby/object:Gem::Version
|
|
92
92
|
version: '0'
|
|
93
93
|
requirements: []
|
|
94
|
-
rubygems_version:
|
|
94
|
+
rubygems_version: 4.0.3
|
|
95
95
|
specification_version: 4
|
|
96
96
|
summary: Support for using the lumberjack logging library in Rails applications.
|
|
97
97
|
test_files: []
|