@@ -97,7 +97,7 @@ defmodule Logger.Translator do
97
97
[ supervisor: sup , errorContext: context ,
98
98
reason: reason ,
99
99
offender: [ { :pid , pid } , { name_or_id , name } | offender ] ] )
100
- when is_pid ( pid ) and context !== :shutdown and name_or_id in [ :name , :id ] do
100
+ when is_pid ( pid ) and context !== :shutdown and name_or_id in [ :name , :id ] do
101
101
{ :ok , [ "Child " , inspect ( name ) , " of Supervisor " ,
102
102
sup_name ( sup ) , ?\s , sup_context ( context ) ,
103
103
"\n ** (exit) " , offender_reason ( reason , context ) ,
@@ -106,37 +106,37 @@ defmodule Logger.Translator do
106
106
end
107
107
108
108
defp translate_supervisor ( min_level ,
109
- [ supervisor: sup , errorContext: context ,
109
+ [ supervisor: sup , errorContext: context ,
110
110
reason: reason ,
111
111
offender: [ { :pid , _pid } ,
112
112
{ name_or_id , name } | offender ] ] ) when name_or_id in [ :name , :id ] do
113
113
{ :ok , [ "Child " , inspect ( name ) , " of Supervisor " ,
114
- sup_name ( sup ) , ?\s , sup_context ( context ) ,
115
- "\n ** (exit) " , offender_reason ( reason , context ) |
116
- child_info ( min_level , offender ) ] }
114
+ sup_name ( sup ) , ?\s , sup_context ( context ) ,
115
+ "\n ** (exit) " , offender_reason ( reason , context ) |
116
+ child_info ( min_level , offender ) ] }
117
117
end
118
118
119
119
defp translate_supervisor ( min_level ,
120
- [ supervisor: sup , errorContext: context ,
120
+ [ supervisor: sup , errorContext: context ,
121
121
reason: reason ,
122
122
offender: [ { :pid , pid } | offender ] ] ) do
123
123
{ :ok , [ "Child of Supervisor " ,
124
- sup_name ( sup ) , ?\s , sup_context ( context ) ,
125
- "\n ** (exit) " , offender_reason ( reason , context ) ,
126
- "\n Pid: " , inspect ( pid ) |
127
- child_info ( min_level , offender ) ] }
124
+ sup_name ( sup ) , ?\s , sup_context ( context ) ,
125
+ "\n ** (exit) " , offender_reason ( reason , context ) ,
126
+ "\n Pid: " , inspect ( pid ) |
127
+ child_info ( min_level , offender ) ] }
128
128
end
129
129
130
130
defp translate_supervisor ( min_level ,
131
- [ supervisor: sup , errorContext: context ,
131
+ [ supervisor: sup , errorContext: context ,
132
132
reason: reason ,
133
133
offender: [ { :nb_children , n } ,
134
134
{ name_or_id , name } | offender ] ] ) when name_or_id in [ :name , :id ] do
135
135
{ :ok , [ "Children " , inspect ( name ) , " of Supervisor " ,
136
- sup_name ( sup ) , ?\s , sup_context ( context ) ,
137
- "\n ** (exit) " , offender_reason ( reason , context ) ,
138
- "\n Number: " , inspect ( n ) |
139
- child_info ( min_level , offender ) ] }
136
+ sup_name ( sup ) , ?\s , sup_context ( context ) ,
137
+ "\n ** (exit) " , offender_reason ( reason , context ) ,
138
+ "\n Number: " , inspect ( n ) |
139
+ child_info ( min_level , offender ) ] }
140
140
end
141
141
142
142
defp translate_supervisor ( _min_level , _other ) , do: :none
@@ -148,19 +148,19 @@ defmodule Logger.Translator do
148
148
149
149
defp translate_progress ( min_level ,
150
150
[ supervisor: sup ,
151
- started: [ { :pid , pid } , { name_or_id , name } | started ] ] ) when name_or_id in [ :name , :id ] do
151
+ started: [ { :pid , pid } , { name_or_id , name } | started ] ] ) when name_or_id in [ :name , :id ] do
152
152
{ :ok , [ "Child " , inspect ( name ) , " of Supervisor " ,
153
- sup_name ( sup ) , " started" ,
154
- "\n Pid: " , inspect ( pid ) |
155
- child_info ( min_level , started ) ] }
153
+ sup_name ( sup ) , " started" ,
154
+ "\n Pid: " , inspect ( pid ) |
155
+ child_info ( min_level , started ) ] }
156
156
end
157
157
158
158
defp translate_progress ( min_level ,
159
159
[ supervisor: sup ,
160
- started: [ { :pid , pid } | started ] ] ) do
160
+ started: [ { :pid , pid } | started ] ] ) do
161
161
{ :ok , [ "Child of Supervisor " , sup_name ( sup ) , " started" ,
162
- "\n Pid: " , inspect ( pid ) |
163
- child_info ( min_level , started ) ] }
162
+ "\n Pid: " , inspect ( pid ) |
163
+ child_info ( min_level , started ) ] }
164
164
end
165
165
166
166
defp translate_progress ( _min_level , _other ) , do: :none
@@ -177,17 +177,17 @@ defmodule Logger.Translator do
177
177
178
178
defp child_info ( min_level , [ { :mfargs , { mod , fun , args } } | debug ] ) do
179
179
[ "\n Start Call: " , format_mfa ( mod , fun , args ) |
180
- child_debug ( min_level , debug ) ]
180
+ child_debug ( min_level , debug ) ]
181
181
end
182
182
183
183
defp child_info ( min_level , [ { :mfa , { mod , fun , args } } | debug ] ) do
184
184
[ "\n Start Call: " , format_mfa ( mod , fun , args ) |
185
- child_debug ( min_level , debug ) ]
185
+ child_debug ( min_level , debug ) ]
186
186
end
187
187
188
188
defp child_info ( min_level , [ { :mod , mod } | debug ] ) do
189
189
[ "\n Start Module: " , inspect ( mod ) |
190
- child_debug ( min_level , debug ) ]
190
+ child_debug ( min_level , debug ) ]
191
191
end
192
192
193
193
defp child_debug ( :debug ,
@@ -217,9 +217,9 @@ defmodule Logger.Translator do
217
217
{ :error_info , { kind , exception , stack } } | crashed ] ,
218
218
linked ] ) do
219
219
{ :ok , [ "Process " , crash_name ( pid , name ) , " terminating" ,
220
- format ( kind , exception , stack ) ,
221
- crash_info ( min_level , [ initial_call | crashed ] ) |
222
- crash_linked ( min_level , linked ) ] }
220
+ format ( kind , exception , stack ) ,
221
+ crash_info ( min_level , [ initial_call | crashed ] ) |
222
+ crash_linked ( min_level , linked ) ] }
223
223
end
224
224
225
225
defp translate_crash ( min_level ,
@@ -228,9 +228,9 @@ defmodule Logger.Translator do
228
228
{ :error_info , { kind , exception , stack } } | crashed ] ,
229
229
linked ] ) do
230
230
{ :ok , [ "Process " , crash_name ( pid , name ) , " terminating" ,
231
- format ( kind , exception , stack ) ,
232
- crash_info ( min_level , crashed ) ,
233
- crash_linked ( min_level , linked ) ] }
231
+ format ( kind , exception , stack ) ,
232
+ crash_info ( min_level , crashed ) ,
233
+ crash_linked ( min_level , linked ) ] }
234
234
end
235
235
236
236
defp crash_name ( pid , [ ] ) , do: inspect ( pid )
@@ -241,13 +241,13 @@ defmodule Logger.Translator do
241
241
defp crash_info ( min_level ,
242
242
[ { :initial_call , { mod , fun , args } } | info ] , prefix ) do
243
243
[ prefix , "Initial Call: " , crash_call ( mod , fun , args ) |
244
- crash_info ( min_level , info , prefix ) ]
244
+ crash_info ( min_level , info , prefix ) ]
245
245
end
246
246
247
247
defp crash_info ( min_level ,
248
248
[ { :current_function , { mod , fun , args } } | info ] , prefix ) do
249
249
[ prefix , "Current Call: " , crash_call ( mod , fun , args ) |
250
- crash_info ( min_level , info , prefix ) ]
250
+ crash_info ( min_level , info , prefix ) ]
251
251
end
252
252
253
253
defp crash_info ( min_level , [ { :current_function , [ ] } | info ] , prefix ) do
@@ -257,7 +257,7 @@ defmodule Logger.Translator do
257
257
defp crash_info ( min_level ,
258
258
[ { :ancestors , ancestors } | debug ] , prefix ) do
259
259
[ prefix , "Ancestors: " , inspect ( ancestors ) |
260
- crash_debug ( min_level , debug , prefix ) ]
260
+ crash_debug ( min_level , debug , prefix ) ]
261
261
end
262
262
263
263
defp crash_call ( mod , fun , arity ) when is_integer ( arity ) do
@@ -270,16 +270,16 @@ defmodule Logger.Translator do
270
270
271
271
defp crash_debug ( :debug ,
272
272
[ messages: msgs , links: links , dictionary: dict ,
273
- trap_exit: trap , status: status , heap_size: heap_size ,
274
- stack_size: stack_size , reductions: reductions ] , prefix ) do
273
+ trap_exit: trap , status: status , heap_size: heap_size ,
274
+ stack_size: stack_size , reductions: reductions ] , prefix ) do
275
275
[ prefix , "Messages: " , inspect ( msgs ) ,
276
- prefix , "Links: " , inspect ( links ) ,
277
- prefix , "Dictionary: " , inspect ( dict ) ,
278
- prefix , "Trapping Exits: " , inspect ( trap ) ,
279
- prefix , "Status: " , inspect ( status ) ,
280
- prefix , "Heap Size: " , inspect ( heap_size ) ,
281
- prefix , "Stack Size: " , inspect ( stack_size ) ,
282
- prefix , "Reductions: " , inspect ( reductions ) ]
276
+ prefix , "Links: " , inspect ( links ) ,
277
+ prefix , "Dictionary: " , inspect ( dict ) ,
278
+ prefix , "Trapping Exits: " , inspect ( trap ) ,
279
+ prefix , "Status: " , inspect ( status ) ,
280
+ prefix , "Heap Size: " , inspect ( heap_size ) ,
281
+ prefix , "Stack Size: " , inspect ( stack_size ) ,
282
+ prefix , "Reductions: " , inspect ( reductions ) ]
283
283
end
284
284
285
285
defp crash_debug ( _min_level , _info , _prefix ) do
@@ -298,14 +298,14 @@ defmodule Logger.Translator do
298
298
[ { :pid , pid } , { :registered_name , [ ] } | info ] ) do
299
299
indent = " "
300
300
[ ?\n , indent , inspect ( pid ) |
301
- crash_info ( min_level , info , [ ?\n , indent | indent ] ) ]
301
+ crash_info ( min_level , info , [ ?\n , indent | indent ] ) ]
302
302
end
303
303
304
304
defp crash_neighbour ( min_level ,
305
305
[ { :pid , pid } , { :registered_name , name } | info ] ) do
306
306
indent = " "
307
307
[ ?\n , indent , inspect ( name ) , " (" , inspect ( pid ) , ")" |
308
- crash_info ( min_level , info , [ ?\n , indent | indent ] ) ]
308
+ crash_info ( min_level , info , [ ?\n , indent | indent ] ) ]
309
309
end
310
310
311
311
defp format_stop ( { maybe_exception , [ _ | _ ] = maybe_stacktrace } = reason ) do
@@ -316,8 +316,7 @@ defmodule Logger.Translator do
316
316
format_stop_banner ( reason )
317
317
else
318
318
formatted_stacktrace ->
319
- [ format_stop_banner ( maybe_exception , maybe_stacktrace ) |
320
- formatted_stacktrace ]
319
+ [ format_stop_banner ( maybe_exception , maybe_stacktrace ) | formatted_stacktrace ]
321
320
end
322
321
end
323
322
@@ -333,7 +332,7 @@ defmodule Logger.Translator do
333
332
@ gen_undef [ :"module could not be loaded" , :"function not exported" ]
334
333
335
334
defp format_stop_banner ( undef , [ { mod , fun , args , _info } | _ ] = stacktrace )
336
- when undef in @ gen_undef and is_atom ( mod ) and is_atom ( fun ) do
335
+ when undef in @ gen_undef and is_atom ( mod ) and is_atom ( fun ) do
337
336
cond do
338
337
is_list ( args ) ->
339
338
format_undef ( mod , fun , length ( args ) , undef , stacktrace )
@@ -345,8 +344,11 @@ defmodule Logger.Translator do
345
344
end
346
345
347
346
defp format_stop_banner ( reason , stacktrace ) do
347
+ # If this is already an exception (even an ErlangError), we format it as an
348
+ # exception. Otherwise, we try to normalize it, and if it's normalized as an
349
+ # ErlangError we instead format it as an exit.
348
350
if Exception . exception? ( reason ) do
349
- [ ?\n | Exception . format_banner ( :error , reason , stacktrace ) ]
351
+ [ ?\n | Exception . format_banner ( :error , reason , stacktrace ) ]
350
352
else
351
353
case Exception . normalize ( :error , reason , stacktrace ) do
352
354
% ErlangError { } ->
@@ -369,9 +371,9 @@ defmodule Logger.Translator do
369
371
end
370
372
371
373
defp format_stacktrace ( stacktrace ) do
372
- for entry <- stacktrace do
373
- [ << "\n " >> | Exception . format_stacktrace_entry ( entry ) ]
374
- end
374
+ for entry <- stacktrace do
375
+ [ << "\n " >> | Exception . format_stacktrace_entry ( entry ) ]
376
+ end
375
377
end
376
378
377
379
defp format_mfa ( mod , fun , :undefined ) , do: [ inspect ( mod ) , ?. , to_string ( fun ) | "/?" ]
0 commit comments