rails_semantic_logger 4.4.5 → 4.4.6
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de0436e82a0d6ed583904e4da19a5dbc5611e7673b1b9904b0b4757f00e71057
|
|
4
|
+
data.tar.gz: 42335c2218f2d434f352f695c9ce2cc9362c7b7cbe70664a3585d5910c91e6f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e0681cc160523f2cef6b6c5fdb169147150bf26470ce628210877e41691911fd81c0f800320dea191d61c6e7be0e3b2ad9d6bf259d0b711caad1c934ec914a72
|
|
7
|
+
data.tar.gz: 3e276c344146b0b16b71b1bfa915b0e8d602c20c750322fca09179c95ac3d85a1138e7b8bbaa96fc62f30effaf09d36cde8e5e7eb8268edbcf3f0e7f1c597f3c
|
|
@@ -38,8 +38,12 @@ module RailsSemanticLogger
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
payload[:status_message] = ::Rack::Utils::HTTP_STATUS_CODES[payload[:status]] if payload[:status].present?
|
|
41
|
+
|
|
41
42
|
# Causes excessive log output with Rails 5 RC1
|
|
42
43
|
payload.delete(:headers)
|
|
44
|
+
# Causes recursion in Rails 6.1.rc1
|
|
45
|
+
payload.delete(:request)
|
|
46
|
+
payload.delete(:response)
|
|
43
47
|
|
|
44
48
|
params = payload[:params]
|
|
45
49
|
if params
|
|
@@ -33,191 +33,184 @@ module RailsSemanticLogger
|
|
|
33
33
|
initializer :initialize_logger, group: :all do
|
|
34
34
|
config = Rails.application.config
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
SemanticLogger.default_level = config.log_level
|
|
36
|
+
# Set the default log level based on the Rails config
|
|
37
|
+
SemanticLogger.default_level = config.log_level
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
if defined?(Rails::Rack::Logger) && config.rails_semantic_logger.semantic
|
|
40
|
+
config.middleware.swap(Rails::Rack::Logger, RailsSemanticLogger::Rack::Logger, config.log_tags)
|
|
41
|
+
end
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
)
|
|
64
|
-
appender.name = "SemanticLogger"
|
|
65
|
-
SemanticLogger::Processor.logger = appender
|
|
66
|
-
|
|
67
|
-
# Check for previous file or stdout loggers
|
|
68
|
-
SemanticLogger.appenders.each { |app| app.formatter = formatter if app.is_a?(SemanticLogger::Appender::File) }
|
|
69
|
-
SemanticLogger.add_appender(file_name: path, formatter: formatter, filter: config.rails_semantic_logger.filter)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
SemanticLogger[Rails]
|
|
73
|
-
rescue StandardError => e
|
|
74
|
-
# If not able to log to file, log to standard error with warning level only
|
|
75
|
-
SemanticLogger.default_level = :warn
|
|
76
|
-
|
|
77
|
-
SemanticLogger::Processor.logger = SemanticLogger::Appender::File.new(io: STDERR)
|
|
78
|
-
SemanticLogger.add_appender(io: STDERR)
|
|
79
|
-
|
|
80
|
-
logger = SemanticLogger[Rails]
|
|
81
|
-
logger.warn(
|
|
82
|
-
"Rails Error: Unable to access log file. Please ensure that #{path} exists and is chmod 0666. " \
|
|
83
|
-
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.",
|
|
84
|
-
e
|
|
43
|
+
# Existing loggers are ignored because servers like trinidad supply their
|
|
44
|
+
# own file loggers which would result in duplicate logging to the same log file
|
|
45
|
+
Rails.logger = config.logger =
|
|
46
|
+
begin
|
|
47
|
+
if config.rails_semantic_logger.add_file_appender
|
|
48
|
+
path = config.paths["log"].first
|
|
49
|
+
FileUtils.mkdir_p(File.dirname(path)) unless File.exist?(File.dirname(path))
|
|
50
|
+
|
|
51
|
+
# Add the log file to the list of appenders
|
|
52
|
+
# Use the colorized formatter if Rails colorized logs are enabled
|
|
53
|
+
ap_options = config.rails_semantic_logger.ap_options
|
|
54
|
+
formatter = config.rails_semantic_logger.format
|
|
55
|
+
formatter = {color: {ap: ap_options}} if (formatter == :default) && (config.colorize_logging != false)
|
|
56
|
+
|
|
57
|
+
# Set internal logger to log to file only, in case another appender experiences errors during writes
|
|
58
|
+
appender = SemanticLogger::Appender::File.new(
|
|
59
|
+
file_name: path,
|
|
60
|
+
level: config.log_level,
|
|
61
|
+
formatter: formatter
|
|
85
62
|
)
|
|
86
|
-
|
|
63
|
+
appender.name = "SemanticLogger"
|
|
64
|
+
SemanticLogger::Processor.logger = appender
|
|
65
|
+
|
|
66
|
+
# Check for previous file or stdout loggers
|
|
67
|
+
SemanticLogger.appenders.each { |app| app.formatter = formatter if app.is_a?(SemanticLogger::Appender::File) }
|
|
68
|
+
SemanticLogger.add_appender(file_name: path, formatter: formatter, filter: config.rails_semantic_logger.filter)
|
|
87
69
|
end
|
|
88
70
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
71
|
+
SemanticLogger[Rails]
|
|
72
|
+
rescue StandardError => e
|
|
73
|
+
# If not able to log to file, log to standard error with warning level only
|
|
74
|
+
SemanticLogger.default_level = :warn
|
|
75
|
+
|
|
76
|
+
SemanticLogger::Processor.logger = SemanticLogger::Appender::File.new(io: STDERR)
|
|
77
|
+
SemanticLogger.add_appender(io: STDERR)
|
|
78
|
+
|
|
79
|
+
logger = SemanticLogger[Rails]
|
|
80
|
+
logger.warn(
|
|
81
|
+
"Rails Error: Unable to access log file. Please ensure that #{path} exists and is chmod 0666. " \
|
|
82
|
+
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.",
|
|
83
|
+
e
|
|
84
|
+
)
|
|
85
|
+
logger
|
|
92
86
|
end
|
|
93
|
-
|
|
87
|
+
|
|
88
|
+
# Replace Rails loggers
|
|
89
|
+
%i[active_record action_controller action_mailer action_view].each do |name|
|
|
90
|
+
ActiveSupport.on_load(name) { include SemanticLogger::Loggable }
|
|
94
91
|
end
|
|
92
|
+
ActiveSupport.on_load(:action_cable) { self.logger = SemanticLogger["ActionCable"] }
|
|
95
93
|
end
|
|
96
94
|
|
|
97
95
|
# Before any initializers run, but after the gems have been loaded
|
|
98
96
|
config.before_initialize do
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
config.rails_semantic_logger.quiet_assets = true if config.assets.quiet
|
|
97
|
+
if config.respond_to?(:assets) && defined?(Rails::Rack::Logger) && config.rails_semantic_logger.semantic
|
|
98
|
+
config.rails_semantic_logger.quiet_assets = true if config.assets.quiet
|
|
102
99
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
# Replace the Mongo Loggers
|
|
108
|
-
Mongoid.logger = SemanticLogger[Mongoid] if defined?(Mongoid)
|
|
109
|
-
Moped.logger = SemanticLogger[Moped] if defined?(Moped)
|
|
110
|
-
Mongo::Logger.logger = SemanticLogger[Mongo] if defined?(Mongo::Logger)
|
|
100
|
+
# Otherwise Sprockets can't find the Rails::Rack::Logger middleware
|
|
101
|
+
config.assets.quiet = false
|
|
102
|
+
end
|
|
111
103
|
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
# Replace the Mongo Loggers
|
|
105
|
+
Mongoid.logger = SemanticLogger[Mongoid] if defined?(Mongoid)
|
|
106
|
+
Moped.logger = SemanticLogger[Moped] if defined?(Moped)
|
|
107
|
+
Mongo::Logger.logger = SemanticLogger[Mongo] if defined?(Mongo::Logger)
|
|
114
108
|
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
# Replace the Resque Logger
|
|
110
|
+
Resque.logger = SemanticLogger[Resque] if defined?(Resque) && Resque.respond_to?(:logger)
|
|
117
111
|
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
# Replace the Sidekiq logger
|
|
113
|
+
Sidekiq.logger = SemanticLogger[Sidekiq] if defined?(Sidekiq)
|
|
120
114
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
Delayed::Worker.logger = SemanticLogger[Delayed::Worker]
|
|
124
|
-
Delayed::Worker.plugins << RailsSemanticLogger::DelayedJob::Plugin
|
|
125
|
-
end
|
|
115
|
+
# Replace the Sidetiq logger
|
|
116
|
+
Sidetiq.logger = SemanticLogger[Sidetiq] if defined?(Sidetiq)
|
|
126
117
|
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
# Replace the DelayedJob logger
|
|
119
|
+
if defined?(Delayed::Worker)
|
|
120
|
+
Delayed::Worker.logger = SemanticLogger[Delayed::Worker]
|
|
121
|
+
Delayed::Worker.plugins << RailsSemanticLogger::DelayedJob::Plugin
|
|
129
122
|
end
|
|
123
|
+
|
|
124
|
+
# Replace the Bugsnag logger
|
|
125
|
+
Bugsnag.configure { |config| config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
|
|
130
126
|
end
|
|
131
127
|
|
|
132
128
|
# After any initializers run, but after the gems have been loaded
|
|
133
129
|
config.after_initialize do
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
require("rails_semantic_logger/extensions/active_model_serializers/logging") if defined?(ActiveModelSerializers)
|
|
147
|
-
require("rails_semantic_logger/extensions/rails/server") if defined?(Rails::Server)
|
|
148
|
-
|
|
149
|
-
if config.rails_semantic_logger.semantic
|
|
150
|
-
# Active Job
|
|
151
|
-
if defined?(::ActiveJob) && defined?(::ActiveJob::Logging::LogSubscriber)
|
|
152
|
-
RailsSemanticLogger.swap_subscriber(
|
|
153
|
-
::ActiveJob::Logging::LogSubscriber,
|
|
154
|
-
RailsSemanticLogger::ActiveJob::LogSubscriber,
|
|
155
|
-
:active_job
|
|
156
|
-
)
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
if defined?(::ActiveJob) && defined?(::ActiveJob::LogSubscriber)
|
|
160
|
-
RailsSemanticLogger.swap_subscriber(
|
|
161
|
-
::ActiveJob::LogSubscriber,
|
|
162
|
-
RailsSemanticLogger::ActiveJob::LogSubscriber,
|
|
163
|
-
:active_job
|
|
164
|
-
)
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
# Active Record
|
|
168
|
-
if defined?(::ActiveRecord)
|
|
169
|
-
require "active_record/log_subscriber"
|
|
170
|
-
|
|
171
|
-
RailsSemanticLogger.swap_subscriber(
|
|
172
|
-
::ActiveRecord::LogSubscriber,
|
|
173
|
-
RailsSemanticLogger::ActiveRecord::LogSubscriber,
|
|
174
|
-
:active_record
|
|
175
|
-
)
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
# Rack
|
|
179
|
-
RailsSemanticLogger::Rack::Logger.started_request_log_level = :info if config.rails_semantic_logger.started
|
|
130
|
+
# Replace the Bugsnag logger
|
|
131
|
+
Bugsnag.configure { |config| config.logger = SemanticLogger[Bugsnag] } if defined?(Bugsnag)
|
|
132
|
+
|
|
133
|
+
# Rails Patches
|
|
134
|
+
require("rails_semantic_logger/extensions/action_cable/tagged_logger_proxy") if defined?(ActionCable)
|
|
135
|
+
require("rails_semantic_logger/extensions/action_controller/live") if defined?(ActionController::Live)
|
|
136
|
+
require("rails_semantic_logger/extensions/action_dispatch/debug_exceptions") if defined?(ActionDispatch::DebugExceptions)
|
|
137
|
+
if defined?(ActionView::StreamingTemplateRenderer::Body)
|
|
138
|
+
require("rails_semantic_logger/extensions/action_view/streaming_template_renderer")
|
|
139
|
+
end
|
|
140
|
+
require("rails_semantic_logger/extensions/active_job/logging") if defined?(::ActiveJob)
|
|
141
|
+
require("rails_semantic_logger/extensions/active_model_serializers/logging") if defined?(ActiveModelSerializers)
|
|
180
142
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
143
|
+
if config.rails_semantic_logger.semantic
|
|
144
|
+
# Active Job
|
|
145
|
+
if defined?(::ActiveJob) && defined?(::ActiveJob::Logging::LogSubscriber)
|
|
146
|
+
RailsSemanticLogger.swap_subscriber(
|
|
147
|
+
::ActiveJob::Logging::LogSubscriber,
|
|
148
|
+
RailsSemanticLogger::ActiveJob::LogSubscriber,
|
|
149
|
+
:active_job
|
|
150
|
+
)
|
|
151
|
+
end
|
|
186
152
|
|
|
187
|
-
|
|
188
|
-
RailsSemanticLogger::ActionView::LogSubscriber.rendered_log_level = :info if config.rails_semantic_logger.rendered
|
|
153
|
+
if defined?(::ActiveJob) && defined?(::ActiveJob::LogSubscriber)
|
|
189
154
|
RailsSemanticLogger.swap_subscriber(
|
|
190
|
-
::
|
|
191
|
-
RailsSemanticLogger::
|
|
192
|
-
:
|
|
155
|
+
::ActiveJob::LogSubscriber,
|
|
156
|
+
RailsSemanticLogger::ActiveJob::LogSubscriber,
|
|
157
|
+
:active_job
|
|
193
158
|
)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Active Record
|
|
162
|
+
if defined?(::ActiveRecord)
|
|
163
|
+
require "active_record/log_subscriber"
|
|
194
164
|
|
|
195
|
-
# Action Controller
|
|
196
165
|
RailsSemanticLogger.swap_subscriber(
|
|
197
|
-
::
|
|
198
|
-
RailsSemanticLogger::
|
|
199
|
-
:
|
|
166
|
+
::ActiveRecord::LogSubscriber,
|
|
167
|
+
RailsSemanticLogger::ActiveRecord::LogSubscriber,
|
|
168
|
+
:active_record
|
|
200
169
|
)
|
|
201
170
|
end
|
|
202
171
|
|
|
203
|
-
#
|
|
204
|
-
|
|
205
|
-
#
|
|
172
|
+
# Rack
|
|
173
|
+
RailsSemanticLogger::Rack::Logger.started_request_log_level = :info if config.rails_semantic_logger.started
|
|
206
174
|
|
|
207
|
-
#
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
SemanticLogger.reopen if forked
|
|
212
|
-
end
|
|
175
|
+
# Silence asset logging by applying a filter to the Rails logger itself, not any of the appenders.
|
|
176
|
+
if config.rails_semantic_logger.quiet_assets && config.assets.prefix
|
|
177
|
+
assets_regex = %r(\A/{0,2}#{config.assets.prefix})
|
|
178
|
+
RailsSemanticLogger::Rack::Logger.logger.filter = ->(log) { log.payload[:path] !~ assets_regex if log.payload }
|
|
213
179
|
end
|
|
214
180
|
|
|
215
|
-
#
|
|
216
|
-
|
|
181
|
+
# Action View
|
|
182
|
+
RailsSemanticLogger::ActionView::LogSubscriber.rendered_log_level = :info if config.rails_semantic_logger.rendered
|
|
183
|
+
RailsSemanticLogger.swap_subscriber(
|
|
184
|
+
::ActionView::LogSubscriber,
|
|
185
|
+
RailsSemanticLogger::ActionView::LogSubscriber,
|
|
186
|
+
:action_view
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
# Action Controller
|
|
190
|
+
RailsSemanticLogger.swap_subscriber(
|
|
191
|
+
::ActionController::LogSubscriber,
|
|
192
|
+
RailsSemanticLogger::ActionController::LogSubscriber,
|
|
193
|
+
:action_controller
|
|
194
|
+
)
|
|
195
|
+
end
|
|
217
196
|
|
|
218
|
-
|
|
219
|
-
|
|
197
|
+
#
|
|
198
|
+
# Forking Frameworks
|
|
199
|
+
#
|
|
200
|
+
|
|
201
|
+
# Passenger provides the :starting_worker_process event for executing
|
|
202
|
+
# code after it has forked, so we use that and reconnect immediately.
|
|
203
|
+
if defined?(PhusionPassenger)
|
|
204
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
|
205
|
+
SemanticLogger.reopen if forked
|
|
206
|
+
end
|
|
220
207
|
end
|
|
208
|
+
|
|
209
|
+
# Re-open appenders after Resque has forked a worker
|
|
210
|
+
Resque.after_fork { |_job| ::SemanticLogger.reopen } if defined?(Resque)
|
|
211
|
+
|
|
212
|
+
# Re-open appenders after Spring has forked a process
|
|
213
|
+
Spring.after_fork { |_job| ::SemanticLogger.reopen } if defined?(Spring.after_fork)
|
|
221
214
|
end
|
|
222
215
|
end
|
|
223
216
|
end
|
|
@@ -98,7 +98,7 @@ module RailsSemanticLogger
|
|
|
98
98
|
# config.rails_semantic_logger.named_tags = nil
|
|
99
99
|
class Options
|
|
100
100
|
attr_accessor :semantic, :started, :processing, :rendered, :ap_options, :add_file_appender,
|
|
101
|
-
:quiet_assets, :format, :named_tags, :filter
|
|
101
|
+
:quiet_assets, :format, :named_tags, :filter
|
|
102
102
|
|
|
103
103
|
# Setup default values
|
|
104
104
|
def initialize
|
|
@@ -112,7 +112,6 @@ module RailsSemanticLogger
|
|
|
112
112
|
@format = :default
|
|
113
113
|
@named_tags = nil
|
|
114
114
|
@filter = nil
|
|
115
|
-
@disabled = false
|
|
116
115
|
end
|
|
117
116
|
end
|
|
118
117
|
end
|
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.
|
|
4
|
+
version: 4.4.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Reid Morrison
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-12-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rack
|
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
98
98
|
- !ruby/object:Gem::Version
|
|
99
99
|
version: '0'
|
|
100
100
|
requirements: []
|
|
101
|
-
rubygems_version: 3.
|
|
101
|
+
rubygems_version: 3.0.8
|
|
102
102
|
signing_key:
|
|
103
103
|
specification_version: 4
|
|
104
104
|
summary: Feature rich logging framework that replaces the Rails logger.
|