File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
railties/lib/rails/generators/rails/app/templates/config/environments Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,11 @@ def self.extended(base)
113
113
end
114
114
end
115
115
116
+ # Returns an `ActiveSupport::Logger` that has already been wrapped with tagged logging concern.
117
+ def self . logger ( *args , **kwargs )
118
+ new ActiveSupport ::Logger . new ( *args , **kwargs )
119
+ end
120
+
116
121
def self . new ( logger )
117
122
logger = logger . clone
118
123
Original file line number Diff line number Diff line change @@ -142,6 +142,14 @@ def flush(*)
142
142
143
143
assert_equal "[BCX] [Jason] Funky time\n [BCX] Junky time!\n " , @output . string
144
144
end
145
+
146
+ test "implicit logger instance" do
147
+ @output = StringIO . new
148
+ @logger = ActiveSupport ::TaggedLogging . logger ( @output )
149
+
150
+ @logger . tagged ( "BCX" ) { @logger . info "Funky time" }
151
+ assert_equal "[BCX] Funky time\n " , @output . string
152
+ end
145
153
end
146
154
147
155
class TaggedLoggingWithoutBlockTest < ActiveSupport ::TestCase
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ Rails.application.configure do
55
55
56
56
# Log to STDOUT with the current request id as a default log tag.
57
57
config.log_tags = [ :request_id ]
58
- config.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new( STDOUT) )
58
+ config.logger = ActiveSupport::TaggedLogging.logger( STDOUT)
59
59
60
60
# "info" includes generic and useful information about system operation, but avoids logging too much
61
61
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
You can’t perform that action at this time.
0 commit comments