rails_semantic_logger 4.4.4 → 4.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/lib/rails_semantic_logger/action_controller/log_subscriber.rb +9 -2
- data/lib/rails_semantic_logger/action_view/log_subscriber.rb +5 -2
- data/lib/rails_semantic_logger/active_job/log_subscriber.rb +17 -8
- data/lib/rails_semantic_logger/active_record/log_subscriber.rb +33 -2
- data/lib/rails_semantic_logger/engine.rb +45 -18
- data/lib/rails_semantic_logger/extensions/action_cable/tagged_logger_proxy.rb +1 -1
- data/lib/rails_semantic_logger/extensions/action_controller/live.rb +3 -1
- data/lib/rails_semantic_logger/extensions/action_dispatch/debug_exceptions.rb +3 -1
- data/lib/rails_semantic_logger/extensions/action_view/streaming_template_renderer.rb +2 -1
- data/lib/rails_semantic_logger/extensions/active_job/logging.rb +1 -0
- data/lib/rails_semantic_logger/extensions/active_support/logger.rb +24 -0
- data/lib/rails_semantic_logger/extensions/active_support/tagged_logging.rb +8 -0
- data/lib/rails_semantic_logger/extensions/mongoid/config.rb +11 -0
- data/lib/rails_semantic_logger/extensions/rack/server.rb +12 -0
- data/lib/rails_semantic_logger/extensions/rails/server.rb +7 -3
- data/lib/rails_semantic_logger/options.rb +7 -2
- data/lib/rails_semantic_logger/rack/logger.rb +1 -1
- data/lib/rails_semantic_logger/version.rb +1 -1
- data/lib/rails_semantic_logger.rb +4 -0
- metadata +17 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e01fc2392ba9faf266764afc12136a13800e8d90eec24c7617c5db4ced6e272
|
4
|
+
data.tar.gz: f0685d627c3891d0cd3b105a1ced10f846bb91e7dd695cf329ac775bce9c6c72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3658cc65b3bfe4c6e1e6f0a5df42b9f66f033250de1fce1e2284e4727096f46e9a3314956198f6cd71299aad7d0708455ce4ecb4744328c0b8ecb8727487f59e
|
7
|
+
data.tar.gz: 6b1dbedd0208a4055156fb6a12c8b06847fdbfab4d2b907252fbaed97ef33474ec50709ad7a6c4a056292c19c61c183c8a32737de16ec7fe59a2bd830913522b
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Rails Semantic Logger
|
2
|
-
[![Gem Version](https://img.shields.io/gem/v/rails_semantic_logger.svg)](https://rubygems.org/gems/rails_semantic_logger) [![Build Status](https://
|
2
|
+
[![Gem Version](https://img.shields.io/gem/v/rails_semantic_logger.svg)](https://rubygems.org/gems/rails_semantic_logger) [![Build Status](https://github.com/reidmorrison/rails_semantic_logger/workflows/build/badge.svg)](https://github.com/reidmorrison/rails_semantic_logger/actions?query=workflow%3Abuild) [![Downloads](https://img.shields.io/gem/dt/rails_semantic_logger.svg)](https://rubygems.org/gems/rails_semantic_logger) [![License](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](http://opensource.org/licenses/Apache-2.0) ![](https://img.shields.io/badge/status-Production%20Ready-blue.svg)
|
3
3
|
|
4
|
-
Rails Semantic Logger replaces the Rails default logger with [Semantic Logger](
|
4
|
+
Rails Semantic Logger replaces the Rails default logger with [Semantic Logger](https://logger.rocketjob.io/)
|
5
5
|
|
6
|
-
* http://github.com/
|
6
|
+
* http://github.com/reidmorrison/rails_semantic_logger
|
7
7
|
|
8
8
|
## Documentation
|
9
9
|
|
10
|
-
For complete documentation see:
|
10
|
+
For complete documentation see: https://logger.rocketjob.io/rails
|
11
11
|
|
12
12
|
## Upgrading to Semantic Logger v4.4
|
13
13
|
|
@@ -21,13 +21,13 @@ SemanticLogger::Processor.instance.instance_variable_set(:@queue, Queue.new)
|
|
21
21
|
|
22
22
|
## Supports
|
23
23
|
|
24
|
-
|
24
|
+
For the complete list of supported Ruby and Rails versions, see the [Testing file](https://github.com/reidmorrison/rails_semantic_logger/blob/master/.travis.yml).
|
25
25
|
|
26
26
|
## Author
|
27
27
|
|
28
28
|
[Reid Morrison](https://github.com/reidmorrison)
|
29
29
|
|
30
|
-
[Contributors](https://github.com/
|
30
|
+
[Contributors](https://github.com/reidmorrison/rails_semantic_logger/graphs/contributors)
|
31
31
|
|
32
32
|
## Versioning
|
33
33
|
|
@@ -15,10 +15,10 @@ module RailsSemanticLogger
|
|
15
15
|
# Unused, but needed for Devise 401 status code monkey patch to still work.
|
16
16
|
::ActionController::Base.log_process_action(payload)
|
17
17
|
|
18
|
-
# According to PR https://github.com/
|
18
|
+
# According to PR https://github.com/reidmorrison/rails_semantic_logger/pull/37/files
|
19
19
|
# payload[:params] is not always a Hash.
|
20
20
|
payload[:params] = payload[:params].to_unsafe_h unless payload[:params].is_a?(Hash)
|
21
|
-
payload[:params].except
|
21
|
+
payload[:params] = payload[:params].except(*INTERNAL_PARAMS)
|
22
22
|
payload.delete(:params) if payload[:params].empty?
|
23
23
|
|
24
24
|
format = payload[:format]
|
@@ -37,9 +37,16 @@ module RailsSemanticLogger
|
|
37
37
|
payload[key] = payload[key].to_f.round(2) if key.to_s =~ /(.*)_runtime/
|
38
38
|
end
|
39
39
|
|
40
|
+
# Rails 6+ includes allocation count
|
41
|
+
payload[:allocations] = event.allocations if event.respond_to?(:allocations)
|
42
|
+
|
40
43
|
payload[:status_message] = ::Rack::Utils::HTTP_STATUS_CODES[payload[:status]] if payload[:status].present?
|
44
|
+
|
41
45
|
# Causes excessive log output with Rails 5 RC1
|
42
46
|
payload.delete(:headers)
|
47
|
+
# Causes recursion in Rails 6.1.rc1
|
48
|
+
payload.delete(:request)
|
49
|
+
payload.delete(:response)
|
43
50
|
|
44
51
|
params = payload[:params]
|
45
52
|
if params
|
@@ -23,6 +23,7 @@ module RailsSemanticLogger
|
|
23
23
|
template: from_rails_root(event.payload[:identifier])
|
24
24
|
}
|
25
25
|
payload[:within] = from_rails_root(event.payload[:layout]) if event.payload[:layout]
|
26
|
+
payload[:allocations] = event.allocations if event.respond_to?(:allocations)
|
26
27
|
|
27
28
|
logger.measure(
|
28
29
|
self.class.rendered_log_level,
|
@@ -39,7 +40,8 @@ module RailsSemanticLogger
|
|
39
40
|
partial: from_rails_root(event.payload[:identifier])
|
40
41
|
}
|
41
42
|
payload[:within] = from_rails_root(event.payload[:layout]) if event.payload[:layout]
|
42
|
-
payload[:cache] = payload[:cache_hit] unless event.payload[:cache_hit].nil?
|
43
|
+
payload[:cache] = event.payload[:cache_hit] unless event.payload[:cache_hit].nil?
|
44
|
+
payload[:allocations] = event.allocations if event.respond_to?(:allocations)
|
43
45
|
|
44
46
|
logger.measure(
|
45
47
|
self.class.rendered_log_level,
|
@@ -58,7 +60,8 @@ module RailsSemanticLogger
|
|
58
60
|
template: from_rails_root(identifier),
|
59
61
|
count: event.payload[:count]
|
60
62
|
}
|
61
|
-
payload[:cache_hits] = payload[:cache_hits] if payload[:cache_hits]
|
63
|
+
payload[:cache_hits] = event.payload[:cache_hits] if event.payload[:cache_hits]
|
64
|
+
payload[:allocations] = event.allocations if event.respond_to?(:allocations)
|
62
65
|
|
63
66
|
logger.measure(
|
64
67
|
self.class.rendered_log_level,
|
@@ -5,29 +5,34 @@ module RailsSemanticLogger
|
|
5
5
|
class LogSubscriber < ::ActiveSupport::LogSubscriber
|
6
6
|
def enqueue(event)
|
7
7
|
log_with_formatter event: event do |fmt|
|
8
|
-
"Enqueued #{fmt.job_info}"
|
8
|
+
{message: "Enqueued #{fmt.job_info}"}
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
def enqueue_at(event)
|
13
13
|
log_with_formatter event: event do |fmt|
|
14
|
-
"Enqueued #{fmt.job_info} at #{fmt.scheduled_at}"
|
14
|
+
{message: "Enqueued #{fmt.job_info} at #{fmt.scheduled_at}"}
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def perform_start(event)
|
19
19
|
log_with_formatter event: event do |fmt|
|
20
|
-
"Performing #{fmt.job_info}"
|
20
|
+
{message: "Performing #{fmt.job_info}"}
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def perform(event)
|
25
25
|
ex = event.payload[:exception_object]
|
26
26
|
if ex
|
27
|
-
|
27
|
+
log_with_formatter event: event, log_duration: true, level: :error do |fmt|
|
28
|
+
{
|
29
|
+
message: "Error performing #{fmt.job_info} in #{event.duration.round(2)}ms",
|
30
|
+
exception: ex
|
31
|
+
}
|
32
|
+
end
|
28
33
|
else
|
29
34
|
log_with_formatter event: event, log_duration: true do |fmt|
|
30
|
-
"Performed #{fmt.job_info} in #{event.duration.round(2)}ms"
|
35
|
+
{message: "Performed #{fmt.job_info} in #{event.duration.round(2)}ms"}
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
@@ -78,7 +83,11 @@ module RailsSemanticLogger
|
|
78
83
|
end
|
79
84
|
|
80
85
|
def formatted_args
|
81
|
-
|
86
|
+
if defined?(job.class.log_arguments?) && !job.class.log_arguments?
|
87
|
+
""
|
88
|
+
else
|
89
|
+
JSON.pretty_generate(job.arguments.map { |arg| format(arg) })
|
90
|
+
end
|
82
91
|
end
|
83
92
|
|
84
93
|
def format(arg)
|
@@ -103,10 +112,10 @@ module RailsSemanticLogger
|
|
103
112
|
end
|
104
113
|
end
|
105
114
|
|
106
|
-
def log_with_formatter(**kw_args)
|
115
|
+
def log_with_formatter(level: :info, **kw_args)
|
107
116
|
fmt = EventFormatter.new(**kw_args)
|
108
117
|
msg = yield fmt
|
109
|
-
logger.
|
118
|
+
logger.public_send(level, **msg, payload: fmt.payload)
|
110
119
|
end
|
111
120
|
|
112
121
|
def logger
|
@@ -31,6 +31,8 @@ module RailsSemanticLogger
|
|
31
31
|
|
32
32
|
log_payload = {sql: payload[:sql]}
|
33
33
|
log_payload[:binds] = bind_values(payload) unless (payload[:binds] || []).empty?
|
34
|
+
log_payload[:allocations] = event.allocations if event.respond_to?(:allocations)
|
35
|
+
log_payload[:cached] = event.payload[:cached]
|
34
36
|
|
35
37
|
log = {
|
36
38
|
message: name,
|
@@ -40,7 +42,7 @@ module RailsSemanticLogger
|
|
40
42
|
|
41
43
|
# Log the location of the query itself.
|
42
44
|
if logger.send(:level_index) >= SemanticLogger.backtrace_level_index
|
43
|
-
log[:backtrace] = SemanticLogger::Utils.strip_backtrace
|
45
|
+
log[:backtrace] = SemanticLogger::Utils.strip_backtrace(caller)
|
44
46
|
end
|
45
47
|
|
46
48
|
logger.debug(log)
|
@@ -52,7 +54,7 @@ module RailsSemanticLogger
|
|
52
54
|
|
53
55
|
# When multiple values are received for a single bound field, it is converted into an array
|
54
56
|
def add_bind_value(binds, key, value)
|
55
|
-
key = key.downcase.to_sym
|
57
|
+
key = key.downcase.to_sym unless key.nil?
|
56
58
|
value = (Array(binds[key]) << value) if binds.key?(key)
|
57
59
|
binds[key] = value
|
58
60
|
end
|
@@ -115,6 +117,16 @@ module RailsSemanticLogger
|
|
115
117
|
binds
|
116
118
|
end
|
117
119
|
|
120
|
+
def bind_values_v6_1(payload)
|
121
|
+
binds = {}
|
122
|
+
casted_params = type_casted_binds(payload[:type_casted_binds])
|
123
|
+
payload[:binds].each_with_index do |attr, i|
|
124
|
+
attr_name, value = render_bind(attr, casted_params[i])
|
125
|
+
add_bind_value(binds, attr_name, value)
|
126
|
+
end
|
127
|
+
binds
|
128
|
+
end
|
129
|
+
|
118
130
|
def render_bind_v4_2(column, value)
|
119
131
|
if column
|
120
132
|
if column.binary?
|
@@ -154,6 +166,21 @@ module RailsSemanticLogger
|
|
154
166
|
[attr&.name, value]
|
155
167
|
end
|
156
168
|
|
169
|
+
def render_bind_v6_1(attr, value)
|
170
|
+
case attr
|
171
|
+
when ActiveModel::Attribute
|
172
|
+
if attr.type.binary? && attr.value
|
173
|
+
value = "<#{attr.value_for_database.to_s.bytesize} bytes of binary data>"
|
174
|
+
end
|
175
|
+
when Array
|
176
|
+
attr = attr.first
|
177
|
+
else
|
178
|
+
attr = nil
|
179
|
+
end
|
180
|
+
|
181
|
+
[attr&.name || :nil, value]
|
182
|
+
end
|
183
|
+
|
157
184
|
def type_casted_binds_v5_0_3(binds, casted_binds)
|
158
185
|
casted_binds || ::ActiveRecord::Base.connection.type_casted_binds(binds)
|
159
186
|
end
|
@@ -171,6 +198,10 @@ module RailsSemanticLogger
|
|
171
198
|
alias bind_values bind_values_v5_0_3
|
172
199
|
alias render_bind render_bind_v5_0_3
|
173
200
|
alias type_casted_binds type_casted_binds_v5_0_3
|
201
|
+
elsif Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR > 0 # ~> 6.1.0
|
202
|
+
alias bind_values bind_values_v6_1
|
203
|
+
alias render_bind render_bind_v6_1
|
204
|
+
alias type_casted_binds type_casted_binds_v5_1_5
|
174
205
|
elsif Rails::VERSION::MAJOR >= 5 # ~> 5.1.5 && ~> 5.0.7 && 6.x.x
|
175
206
|
alias bind_values bind_values_v5_1_5
|
176
207
|
alias render_bind render_bind_v5_0_3
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rails"
|
2
2
|
require "action_controller/log_subscriber"
|
3
|
+
require "action_view/log_subscriber"
|
3
4
|
require "rails_semantic_logger/options"
|
4
5
|
|
5
6
|
module RailsSemanticLogger
|
@@ -54,16 +55,16 @@ module RailsSemanticLogger
|
|
54
55
|
formatter = {color: {ap: ap_options}} if (formatter == :default) && (config.colorize_logging != false)
|
55
56
|
|
56
57
|
# Set internal logger to log to file only, in case another appender experiences errors during writes
|
57
|
-
appender
|
58
|
-
file_name: path,
|
59
|
-
level: config.log_level,
|
60
|
-
formatter: formatter
|
61
|
-
)
|
58
|
+
appender = SemanticLogger::Appender::File.new(path, formatter: formatter)
|
62
59
|
appender.name = "SemanticLogger"
|
63
60
|
SemanticLogger::Processor.logger = appender
|
64
61
|
|
65
62
|
# Check for previous file or stdout loggers
|
66
|
-
SemanticLogger.appenders.each
|
63
|
+
SemanticLogger.appenders.each do |app|
|
64
|
+
next unless app.is_a?(SemanticLogger::Appender::File) || app.is_a?(SemanticLogger::Appender::IO)
|
65
|
+
|
66
|
+
app.formatter = formatter
|
67
|
+
end
|
67
68
|
SemanticLogger.add_appender(file_name: path, formatter: formatter, filter: config.rails_semantic_logger.filter)
|
68
69
|
end
|
69
70
|
|
@@ -72,13 +73,13 @@ module RailsSemanticLogger
|
|
72
73
|
# If not able to log to file, log to standard error with warning level only
|
73
74
|
SemanticLogger.default_level = :warn
|
74
75
|
|
75
|
-
SemanticLogger::Processor.logger = SemanticLogger::Appender::
|
76
|
-
SemanticLogger.add_appender(io:
|
76
|
+
SemanticLogger::Processor.logger = SemanticLogger::Appender::IO.new($stderr)
|
77
|
+
SemanticLogger.add_appender(io: $stderr)
|
77
78
|
|
78
79
|
logger = SemanticLogger[Rails]
|
79
80
|
logger.warn(
|
80
81
|
"Rails Error: Unable to access log file. Please ensure that #{path} exists and is chmod 0666. " \
|
81
|
-
|
82
|
+
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.",
|
82
83
|
e
|
83
84
|
)
|
84
85
|
logger
|
@@ -122,26 +123,31 @@ module RailsSemanticLogger
|
|
122
123
|
|
123
124
|
# Replace the Bugsnag logger
|
124
125
|
Bugsnag.configure { |config| config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
|
126
|
+
|
127
|
+
# Set the IOStreams PGP logger
|
128
|
+
IOStreams::Pgp.logger = SemanticLogger["IOStreams::Pgp"] if defined?(IOStreams)
|
125
129
|
end
|
126
130
|
|
127
131
|
# After any initializers run, but after the gems have been loaded
|
128
132
|
config.after_initialize do
|
133
|
+
config = Rails.application.config
|
134
|
+
|
129
135
|
# Replace the Bugsnag logger
|
130
|
-
Bugsnag.configure { |
|
136
|
+
Bugsnag.configure { |bugsnag_config| bugsnag_config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
|
131
137
|
|
132
138
|
# Rails Patches
|
133
|
-
require("rails_semantic_logger/extensions/action_cable/tagged_logger_proxy") if defined?(ActionCable)
|
134
|
-
require("rails_semantic_logger/extensions/action_controller/live") if defined?(ActionController::Live)
|
135
|
-
require("rails_semantic_logger/extensions/action_dispatch/debug_exceptions") if defined?(ActionDispatch::DebugExceptions)
|
136
|
-
if defined?(ActionView::StreamingTemplateRenderer::Body)
|
139
|
+
require("rails_semantic_logger/extensions/action_cable/tagged_logger_proxy") if defined?(::ActionCable)
|
140
|
+
require("rails_semantic_logger/extensions/action_controller/live") if defined?(::ActionController::Live)
|
141
|
+
require("rails_semantic_logger/extensions/action_dispatch/debug_exceptions") if defined?(::ActionDispatch::DebugExceptions)
|
142
|
+
if defined?(::ActionView::StreamingTemplateRenderer::Body)
|
137
143
|
require("rails_semantic_logger/extensions/action_view/streaming_template_renderer")
|
138
144
|
end
|
139
|
-
require("rails_semantic_logger/extensions/active_job/logging") if defined?(ActiveJob)
|
140
|
-
require("rails_semantic_logger/extensions/active_model_serializers/logging") if defined?(ActiveModelSerializers)
|
145
|
+
require("rails_semantic_logger/extensions/active_job/logging") if defined?(::ActiveJob)
|
146
|
+
require("rails_semantic_logger/extensions/active_model_serializers/logging") if defined?(::ActiveModelSerializers)
|
141
147
|
|
142
148
|
if config.rails_semantic_logger.semantic
|
143
149
|
# Active Job
|
144
|
-
if defined?(::ActiveJob)
|
150
|
+
if defined?(::ActiveJob) && defined?(::ActiveJob::Logging::LogSubscriber)
|
145
151
|
RailsSemanticLogger.swap_subscriber(
|
146
152
|
::ActiveJob::Logging::LogSubscriber,
|
147
153
|
RailsSemanticLogger::ActiveJob::LogSubscriber,
|
@@ -149,6 +155,14 @@ module RailsSemanticLogger
|
|
149
155
|
)
|
150
156
|
end
|
151
157
|
|
158
|
+
if defined?(::ActiveJob) && defined?(::ActiveJob::LogSubscriber)
|
159
|
+
RailsSemanticLogger.swap_subscriber(
|
160
|
+
::ActiveJob::LogSubscriber,
|
161
|
+
RailsSemanticLogger::ActiveJob::LogSubscriber,
|
162
|
+
:active_job
|
163
|
+
)
|
164
|
+
end
|
165
|
+
|
152
166
|
# Active Record
|
153
167
|
if defined?(::ActiveRecord)
|
154
168
|
require "active_record/log_subscriber"
|
@@ -165,7 +179,8 @@ module RailsSemanticLogger
|
|
165
179
|
|
166
180
|
# Silence asset logging by applying a filter to the Rails logger itself, not any of the appenders.
|
167
181
|
if config.rails_semantic_logger.quiet_assets && config.assets.prefix
|
168
|
-
|
182
|
+
assets_root = config.relative_url_root.to_s + config.assets.prefix
|
183
|
+
assets_regex = %r(\A/{0,2}#{assets_root})
|
169
184
|
RailsSemanticLogger::Rack::Logger.logger.filter = ->(log) { log.payload[:path] !~ assets_regex if log.payload }
|
170
185
|
end
|
171
186
|
|
@@ -202,6 +217,18 @@ module RailsSemanticLogger
|
|
202
217
|
|
203
218
|
# Re-open appenders after Spring has forked a process
|
204
219
|
Spring.after_fork { |_job| ::SemanticLogger.reopen } if defined?(Spring.after_fork)
|
220
|
+
|
221
|
+
console do |_app|
|
222
|
+
# Don't use a background thread for logging
|
223
|
+
SemanticLogger.sync!
|
224
|
+
# Add a stderr logger when running inside a Rails console unless one has already been added.
|
225
|
+
if config.rails_semantic_logger.console_logger && !SemanticLogger.appenders.console_output?
|
226
|
+
SemanticLogger.add_appender(io: STDERR, formatter: :color)
|
227
|
+
end
|
228
|
+
|
229
|
+
# Include method names on log entries in the console
|
230
|
+
SemanticLogger.backtrace_level = SemanticLogger.default_level
|
231
|
+
end
|
205
232
|
end
|
206
233
|
end
|
207
234
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# Log actual exceptions, not a string representation
|
2
|
-
|
2
|
+
require "action_dispatch"
|
3
|
+
|
3
4
|
module ActionDispatch
|
4
5
|
class DebugExceptions
|
5
6
|
private
|
6
7
|
|
8
|
+
undef_method :log_error
|
7
9
|
def log_error(_request, wrapper)
|
8
10
|
ActiveSupport::Deprecation.silence do
|
9
11
|
ActionController::Base.logger.fatal(wrapper.exception)
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# Log actual exceptions, not a string representation
|
2
|
-
|
2
|
+
require "action_view/renderer/streaming_template_renderer"
|
3
3
|
|
4
4
|
module ActionView
|
5
5
|
class StreamingTemplateRenderer
|
6
6
|
class Body
|
7
7
|
private
|
8
8
|
|
9
|
+
undef_method :log_error
|
9
10
|
def log_error(exception)
|
10
11
|
ActionView::Base.logger.fatal(exception)
|
11
12
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "active_support/logger"
|
2
|
+
|
3
|
+
module ActiveSupport
|
4
|
+
# More hacks to try and stop Rails from being it's own worst enemy.
|
5
|
+
class Logger
|
6
|
+
class << self
|
7
|
+
undef :logger_outputs_to?, :broadcast
|
8
|
+
end
|
9
|
+
|
10
|
+
# Prevent Console from trying to merge loggers
|
11
|
+
def self.logger_outputs_to?(*args)
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
# Prevent broadcasting since SemanticLogger already supports multiple loggers
|
16
|
+
def self.broadcast(logger)
|
17
|
+
Module.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.new(*args, **kwargs)
|
21
|
+
SemanticLogger[self]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,11 +1,15 @@
|
|
1
1
|
# Patch the Rails::Server log_to_stdout so that it logs via SemanticLogger
|
2
|
-
|
2
|
+
require "rails"
|
3
|
+
|
3
4
|
module Rails
|
4
5
|
class Server
|
5
6
|
private
|
6
|
-
|
7
|
+
|
8
|
+
undef_method :log_to_stdout
|
7
9
|
def log_to_stdout
|
8
|
-
|
10
|
+
wrapped_app # touch the app so the logger is set up
|
11
|
+
|
12
|
+
SemanticLogger.add_appender(io: $stdout, formatter: :color) unless SemanticLogger.appenders.console_output?
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -40,7 +40,7 @@ module RailsSemanticLogger
|
|
40
40
|
# When Semantic Logger fails to log to an appender it logs the error to an
|
41
41
|
# internal logger, which by default writes to STDERR.
|
42
42
|
# Example, change the default internal logger to log to stdout:
|
43
|
-
# SemanticLogger::Processor.logger = SemanticLogger::Appender::
|
43
|
+
# SemanticLogger::Processor.logger = SemanticLogger::Appender::IO.new($stdout, level: :warn)
|
44
44
|
#
|
45
45
|
# config.rails_semantic_logger.add_file_appender = true
|
46
46
|
#
|
@@ -48,6 +48,10 @@ module RailsSemanticLogger
|
|
48
48
|
#
|
49
49
|
# config.rails_semantic_logger.quiet_assets = false
|
50
50
|
#
|
51
|
+
# * Disable automatic logging to stderr when running a Rails console.
|
52
|
+
#
|
53
|
+
# config.rails_semantic_logger.console_logger = false
|
54
|
+
#
|
51
55
|
# * Override the output format for the primary Rails log file.
|
52
56
|
#
|
53
57
|
# Valid options:
|
@@ -98,7 +102,7 @@ module RailsSemanticLogger
|
|
98
102
|
# config.rails_semantic_logger.named_tags = nil
|
99
103
|
class Options
|
100
104
|
attr_accessor :semantic, :started, :processing, :rendered, :ap_options, :add_file_appender,
|
101
|
-
:quiet_assets, :format, :named_tags, :filter
|
105
|
+
:quiet_assets, :format, :named_tags, :filter, :console_logger
|
102
106
|
|
103
107
|
# Setup default values
|
104
108
|
def initialize
|
@@ -112,6 +116,7 @@ module RailsSemanticLogger
|
|
112
116
|
@format = :default
|
113
117
|
@named_tags = nil
|
114
118
|
@filter = nil
|
119
|
+
@console_logger = true
|
115
120
|
end
|
116
121
|
end
|
117
122
|
end
|
@@ -52,3 +52,7 @@ module RailsSemanticLogger
|
|
52
52
|
|
53
53
|
private_class_method :subscriber_patterns, :unattach
|
54
54
|
end
|
55
|
+
|
56
|
+
require("rails_semantic_logger/extensions/mongoid/config") if defined?(Mongoid)
|
57
|
+
require("rails_semantic_logger/extensions/active_support/logger") if defined?(ActiveSupport::Logger)
|
58
|
+
require("rails_semantic_logger/extensions/rack/server") if defined?(Rack::Server)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_semantic_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -30,31 +30,30 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '5.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '5.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: semantic_logger
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '4.
|
47
|
+
version: '4.9'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '4.
|
55
|
-
description:
|
54
|
+
version: '4.9'
|
55
|
+
description:
|
56
56
|
email:
|
57
|
-
- reidmo@gmail.com
|
58
57
|
executables: []
|
59
58
|
extensions: []
|
60
59
|
extra_rdoc_files: []
|
@@ -75,15 +74,19 @@ files:
|
|
75
74
|
- lib/rails_semantic_logger/extensions/action_view/streaming_template_renderer.rb
|
76
75
|
- lib/rails_semantic_logger/extensions/active_job/logging.rb
|
77
76
|
- lib/rails_semantic_logger/extensions/active_model_serializers/logging.rb
|
77
|
+
- lib/rails_semantic_logger/extensions/active_support/logger.rb
|
78
|
+
- lib/rails_semantic_logger/extensions/active_support/tagged_logging.rb
|
79
|
+
- lib/rails_semantic_logger/extensions/mongoid/config.rb
|
80
|
+
- lib/rails_semantic_logger/extensions/rack/server.rb
|
78
81
|
- lib/rails_semantic_logger/extensions/rails/server.rb
|
79
82
|
- lib/rails_semantic_logger/options.rb
|
80
83
|
- lib/rails_semantic_logger/rack/logger.rb
|
81
84
|
- lib/rails_semantic_logger/version.rb
|
82
|
-
homepage: https://
|
85
|
+
homepage: https://logger.rocketjob.io
|
83
86
|
licenses:
|
84
87
|
- Apache-2.0
|
85
88
|
metadata: {}
|
86
|
-
post_install_message:
|
89
|
+
post_install_message:
|
87
90
|
rdoc_options: []
|
88
91
|
require_paths:
|
89
92
|
- lib
|
@@ -91,15 +94,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
94
|
requirements:
|
92
95
|
- - ">="
|
93
96
|
- !ruby/object:Gem::Version
|
94
|
-
version: '2.
|
97
|
+
version: '2.5'
|
95
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
99
|
requirements:
|
97
100
|
- - ">="
|
98
101
|
- !ruby/object:Gem::Version
|
99
102
|
version: '0'
|
100
103
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
102
|
-
signing_key:
|
104
|
+
rubygems_version: 3.3.3
|
105
|
+
signing_key:
|
103
106
|
specification_version: 4
|
104
107
|
summary: Feature rich logging framework that replaces the Rails logger.
|
105
108
|
test_files: []
|