@@ -123,40 +123,9 @@ class Engine < ::Rails::Engine
123
123
124
124
SemanticLogger . add_appender ( io : $stdout, formatter : :color ) unless SemanticLogger . appenders . console_output?
125
125
126
- # Replace default error handler if present
127
- # Prevent exception logging since the Job Logger already logged the exception.
128
- # Only log the context that was not available during the job_logger call.
129
- if defined? ( ::Sidekiq ::ExceptionHandler )
130
- existing = ::Sidekiq . error_handlers . find { |handler | handler . is_a? ( ::Sidekiq ::ExceptionHandler ::Logger ) }
131
- if existing && config . error_handlers . delete ( existing )
132
- config . error_handlers << -> ( ex , ctx ) do
133
- unless ctx . empty?
134
- job_hash = ctx [ :job ] || { }
135
- klass = job_hash [ "display_class" ] || job_hash [ "wrapped" ] || job_hash [ "class" ]
136
- logger = klass ? SemanticLogger [ klass ] : Sidekiq . logger
137
- ctx [ :context ] ? logger . warn ( ctx [ :context ] , ctx ) : logger . warn ( ctx )
138
- end
139
- end
140
- end
141
- elsif defined? ( ::Sidekiq ::DEFAULT_ERROR_HANDLER ) && config . error_handlers . delete ( ::Sidekiq ::DEFAULT_ERROR_HANDLER )
142
- config . error_handlers << -> ( ex , ctx ) do
143
- unless ctx . empty?
144
- job_hash = ctx [ :job ] || { }
145
- klass = job_hash [ "display_class" ] || job_hash [ "wrapped" ] || job_hash [ "class" ]
146
- logger = klass ? SemanticLogger [ klass ] : Sidekiq . logger
147
- ctx [ :context ] ? logger . warn ( ctx [ :context ] , ctx ) : logger . warn ( ctx )
148
- end
149
- end
150
- elsif defined? ( ::Sidekiq ::Config ::ERROR_HANDLER ) && config . error_handlers . delete ( ::Sidekiq ::Config ::ERROR_HANDLER )
151
- config . error_handlers << -> ( ex , ctx , _default_configuration ) do
152
- unless ctx . empty?
153
- job_hash = ctx [ :job ] || { }
154
- klass = job_hash [ "display_class" ] || job_hash [ "wrapped" ] || job_hash [ "class" ]
155
- logger = klass ? SemanticLogger [ klass ] : Sidekiq . logger
156
- ctx [ :context ] ? logger . warn ( ctx [ :context ] , ctx ) : logger . warn ( ctx )
157
- end
158
- end
159
- end
126
+ # Replace default error handler when present
127
+ existing = RailsSemanticLogger ::Sidekiq ::Defaults . delete_default_error_handler ( config . error_handlers )
128
+ config . error_handlers << RailsSemanticLogger ::Sidekiq ::Defaults ::ERROR_HANDLER if existing
160
129
end
161
130
162
131
if defined? ( ::Sidekiq ::Job )
0 commit comments