@@ -183,8 +183,8 @@ defmodule Logger.TranslatorTest do
183
183
** (RuntimeError) oops
184
184
"""
185
185
186
- assert_receive { :event , { :string , [ "GenServer " <> _ | _ ] } , gen_server_metadata }
187
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
186
+ assert_receive { :event , { :report , % { label: { :gen_server , :terminate } } } , gen_server_metadata }
187
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
188
188
189
189
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = gen_server_metadata [ :crash_reason ]
190
190
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = process_metadata [ :crash_reason ]
@@ -200,8 +200,8 @@ defmodule Logger.TranslatorTest do
200
200
{ :ok , pid } = GenServer . start ( MyGenServer , :ok , name: config . test )
201
201
capture_log ( :info , fn -> catch_exit ( GenServer . call ( pid , :error ) ) end )
202
202
203
- assert_receive { :event , { :string , [ "GenServer " <> _ | _ ] } , gen_server_metadata }
204
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
203
+ assert_receive { :event , { :report , % { label: { :gen_server , :terminate } } } , gen_server_metadata }
204
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
205
205
206
206
assert gen_server_metadata [ :registered_name ] == config . test
207
207
assert process_metadata [ :registered_name ] == config . test
@@ -211,8 +211,8 @@ defmodule Logger.TranslatorTest do
211
211
{ :ok , pid } = GenServer . start ( MyGenServer , :ok , name: { :global , config . test } )
212
212
capture_log ( :info , fn -> catch_exit ( GenServer . call ( pid , :error ) ) end )
213
213
214
- assert_receive { :event , { :string , [ "GenServer " <> _ | _ ] } , gen_server_metadata }
215
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
214
+ assert_receive { :event , { :report , % { label: { :gen_server , :terminate } } } , gen_server_metadata }
215
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
216
216
217
217
assert gen_server_metadata [ :registered_name ] == config . test
218
218
refute Map . has_key? ( process_metadata , :registered_name )
@@ -260,8 +260,8 @@ defmodule Logger.TranslatorTest do
260
260
.*
261
261
""" s
262
262
263
- assert_receive { :event , { :string , [ [ "GenServer " <> _ | _ ] | _ ] } , gen_server_metadata }
264
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
263
+ assert_receive { :event , { :report , % { label: { :gen_server , :terminate } } } , gen_server_metadata }
264
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
265
265
266
266
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = gen_server_metadata [ :crash_reason ]
267
267
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = process_metadata [ :crash_reason ]
@@ -330,8 +330,8 @@ defmodule Logger.TranslatorTest do
330
330
assert_receive { :DOWN , ^ mon , _ , _ , _ }
331
331
end ) =~ "Client"
332
332
333
- assert_receive { :event , { :string , [ [ "GenServer " <> _ | _ ] | _ ] } , _gen_server_metadata }
334
- assert_receive { :event , { :string , [ "Process " | _ ] } , _process_metadata }
333
+ assert_receive { :event , { :report , % { label: { :gen_server , :terminate } } } , _gen_server_metadata }
334
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , _process_metadata }
335
335
end
336
336
337
337
test "translates :gen_event crashes" do
@@ -346,7 +346,7 @@ defmodule Logger.TranslatorTest do
346
346
** (RuntimeError) oops
347
347
"""
348
348
349
- assert_receive { :event , { :string , [ ": gen_event handler " <> _ | _ ] } , metadata }
349
+ assert_receive { :event , { :report , % { label: { : gen_event, :terminate } } } , metadata }
350
350
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = metadata [ :crash_reason ]
351
351
refute Map . has_key? ( metadata , :initial_call )
352
352
refute Map . has_key? ( metadata , :registered_name )
@@ -364,7 +364,7 @@ defmodule Logger.TranslatorTest do
364
364
** (RuntimeError) oops
365
365
"""
366
366
367
- assert_receive { :event , { :string , [ ": gen_event handler " <> _ | _ ] } , metadata }
367
+ assert_receive { :event , { :report , % { label: { : gen_event, :terminate } } } , metadata }
368
368
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = metadata [ :crash_reason ]
369
369
assert metadata [ :registered_name ] == config . test
370
370
end
@@ -402,7 +402,7 @@ defmodule Logger.TranslatorTest do
402
402
State: :ok
403
403
""" s
404
404
405
- assert_receive { :event , { :string , [ [ ": gen_event handler " <> _ | _ ] | _ ] } , metadata }
405
+ assert_receive { :event , { :report , % { label: { : gen_event, :terminate } } } , metadata }
406
406
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = metadata [ :crash_reason ]
407
407
end
408
408
@@ -416,8 +416,8 @@ defmodule Logger.TranslatorTest do
416
416
** (RuntimeError) oops
417
417
"""
418
418
419
- assert_receive { :event , { :string , [ ": gen_statem " <> _ | _ ] } , gen_statem_metadata }
420
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
419
+ assert_receive { :event , { :report , % { label: { : gen_statem, :terminate } } } , gen_statem_metadata }
420
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
421
421
422
422
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = gen_statem_metadata [ :crash_reason ]
423
423
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = process_metadata [ :crash_reason ]
@@ -433,8 +433,8 @@ defmodule Logger.TranslatorTest do
433
433
{ :ok , pid } = :gen_statem . start ( { :local , config . test } , MyGenStatem , :ok , [ ] )
434
434
capture_log ( :info , fn -> catch_exit ( :gen_statem . call ( pid , :error ) ) end )
435
435
436
- assert_receive { :event , { :string , [ ": gen_statem " <> _ | _ ] } , gen_statem_metadata }
437
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
436
+ assert_receive { :event , { :report , % { label: { : gen_statem, :terminate } } } , gen_statem_metadata }
437
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
438
438
439
439
assert gen_statem_metadata [ :registered_name ] == config . test
440
440
assert process_metadata [ :registered_name ] == config . test
@@ -444,8 +444,8 @@ defmodule Logger.TranslatorTest do
444
444
{ :ok , pid } = :gen_statem . start ( { :global , config . test } , MyGenStatem , :ok , [ ] )
445
445
capture_log ( :info , fn -> catch_exit ( :gen_statem . call ( pid , :error ) ) end )
446
446
447
- assert_receive { :event , { :string , [ ": gen_statem " <> _ | _ ] } , gen_statem_metadata }
448
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
447
+ assert_receive { :event , { :report , % { label: { : gen_statem, :terminate } } } , gen_statem_metadata }
448
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
449
449
450
450
assert gen_statem_metadata [ :registered_name ] == config . test
451
451
refute Map . has_key? ( process_metadata , :registered_name )
@@ -498,8 +498,8 @@ defmodule Logger.TranslatorTest do
498
498
.*
499
499
""" s
500
500
501
- assert_receive { :event , { :string , [ [ ": gen_statem " <> _ | _ ] | _ ] } , gen_statem_metadata }
502
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
501
+ assert_receive { :event , { :report , % { label: { : gen_statem, :terminate } } } , gen_statem_metadata }
502
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
503
503
504
504
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = gen_statem_metadata [ :crash_reason ]
505
505
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = process_metadata [ :crash_reason ]
@@ -574,8 +574,8 @@ defmodule Logger.TranslatorTest do
574
574
assert_receive { :DOWN , ^ mon , _ , _ , _ }
575
575
end ) =~ "Client"
576
576
577
- assert_receive { :event , { :string , [ [ ": gen_statem " <> _ | _ ] | _ ] } , _gen_statem_metadata }
578
- assert_receive { :event , { :string , [ "Process " | _ ] } , _process_metadata }
577
+ assert_receive { :event , { :report , % { label: { : gen_statem, :terminate } } } , _gen_statem_metadata }
578
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , _process_metadata }
579
579
end
580
580
581
581
test "translates :gen_statem crashes when callback_mode is :handle_event_function" do
@@ -593,8 +593,8 @@ defmodule Logger.TranslatorTest do
593
593
Callback mode: .*, state_enter: false
594
594
""" s
595
595
596
- assert_receive { :event , { :string , [ [ ": gen_statem " <> _ | _ ] | _ ] } , gen_statem_metadata }
597
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
596
+ assert_receive { :event , { :report , % { label: { : gen_statem, :terminate } } } , gen_statem_metadata }
597
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
598
598
599
599
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = gen_statem_metadata [ :crash_reason ]
600
600
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = process_metadata [ :crash_reason ]
@@ -622,7 +622,7 @@ defmodule Logger.TranslatorTest do
622
622
Args: \[ #PID<\d +\. \d +\. \d +>\]
623
623
""" s
624
624
625
- assert_receive { :event , { :string , [ " Task " <> _ | _ ] } , task_metadata }
625
+ assert_receive { :event , { :report , % { label: { Task.Supervisor , :terminating } } } , task_metadata }
626
626
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = task_metadata [ :crash_reason ]
627
627
assert [ parent ] == task_metadata [ :callers ]
628
628
refute Map . has_key? ( task_metadata , :initial_call )
@@ -643,7 +643,7 @@ defmodule Logger.TranslatorTest do
643
643
Args: \[ \]
644
644
""" s
645
645
646
- assert_receive { :event , { :string , [ " Task " <> _ | _ ] } , task_metadata }
646
+ assert_receive { :event , { :report , % { label: { Task.Supervisor , :terminating } } } , task_metadata }
647
647
assert [ parent ] == task_metadata [ :callers ]
648
648
assert { % UndefinedFunctionError { function: :undef } , [ _ | _ ] } = task_metadata [ :crash_reason ]
649
649
end
@@ -663,7 +663,7 @@ defmodule Logger.TranslatorTest do
663
663
Args: \[ \]
664
664
""" s
665
665
666
- assert_receive { :event , { :string , [ " Task " <> _ | _ ] } , task_metadata }
666
+ assert_receive { :event , { :report , % { label: { Task.Supervisor , :terminating } } } , task_metadata }
667
667
assert [ parent ] == task_metadata [ :callers ]
668
668
assert { % UndefinedFunctionError { function: :undef } , [ _ | _ ] } = task_metadata [ :crash_reason ]
669
669
end
@@ -691,7 +691,7 @@ defmodule Logger.TranslatorTest do
691
691
Args: \[ %ErlangError{.*}\]
692
692
""" s
693
693
694
- assert_receive { :event , { :string , [ " Task " <> _ | _ ] } , task_metadata }
694
+ assert_receive { :event , { :report , % { label: { Task.Supervisor , :terminating } } } , task_metadata }
695
695
assert [ parent ] == task_metadata [ :callers ]
696
696
assert { % ErlangError { original: :foo } , [ _ | _ ] } = task_metadata [ :crash_reason ]
697
697
end
@@ -711,7 +711,7 @@ defmodule Logger.TranslatorTest do
711
711
Args: \[ :badarg\]
712
712
""" s
713
713
714
- assert_receive { :event , { :string , [ " Task " <> _ | _ ] } , task_metadata }
714
+ assert_receive { :event , { :report , % { label: { Task.Supervisor , :terminating } } } , task_metadata }
715
715
assert [ parent ] == task_metadata [ :callers ]
716
716
assert { % ArgumentError { message: "argument error" } , [ _ | _ ] } = task_metadata [ :crash_reason ]
717
717
end
@@ -731,7 +731,7 @@ defmodule Logger.TranslatorTest do
731
731
Args: \[ :abnormal\]
732
732
""" s
733
733
734
- assert_receive { :event , { :string , [ " Task " <> _ | _ ] } , task_metadata }
734
+ assert_receive { :event , { :report , % { label: { Task.Supervisor , :terminating } } } , task_metadata }
735
735
assert [ parent ] == task_metadata [ :callers ]
736
736
assert { :abnormal , [ _ | _ ] } = task_metadata [ :crash_reason ]
737
737
end
@@ -813,7 +813,7 @@ defmodule Logger.TranslatorTest do
813
813
Ancestors: \[ #PID<\d +\. \d +\. \d +>\]
814
814
""" s
815
815
816
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
816
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
817
817
818
818
assert is_pid ( process_metadata [ :pid ] )
819
819
assert is_list ( process_metadata [ :ancestors ] )
@@ -857,7 +857,7 @@ defmodule Logger.TranslatorTest do
857
857
Ancestors: \[ #PID<\d +\. \d +\. \d +>\]
858
858
""" s
859
859
860
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
860
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
861
861
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = process_metadata [ :crash_reason ]
862
862
end
863
863
@@ -884,7 +884,7 @@ defmodule Logger.TranslatorTest do
884
884
Ancestors: \[ #PID<\d +\. \d +\. \d +>\]
885
885
""" s
886
886
887
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
887
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
888
888
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = process_metadata [ :crash_reason ]
889
889
end
890
890
@@ -908,7 +908,7 @@ defmodule Logger.TranslatorTest do
908
908
Ancestors: \[ #PID<\d +\. \d +\. \d +>\]
909
909
""" s
910
910
911
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
911
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
912
912
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = process_metadata [ :crash_reason ]
913
913
end
914
914
@@ -1051,7 +1051,7 @@ defmodule Logger.TranslatorTest do
1051
1051
Start Call: Logger.TranslatorTest.undef\( \)
1052
1052
""" s
1053
1053
1054
- assert_receive { :event , { :string , [ "Child " | _ ] } , _child_metadata }
1054
+ assert_receive { :event , { :report , % { label: { :supervisor , :start_error } } } , _child_metadata }
1055
1055
end
1056
1056
1057
1057
test "translates Supervisor reports terminated" do
@@ -1068,9 +1068,12 @@ defmodule Logger.TranslatorTest do
1068
1068
Start Call: Task.start_link\( Kernel, :exit, \[ :stop\] \)
1069
1069
"""
1070
1070
1071
- assert_receive { :event , { :string , [ "Task " <> _ | _ ] } , task_metadata }
1072
- assert_receive { :event , { :string , [ "Child " | _ ] } , _child_metadata }
1073
- assert_receive { :event , { :string , [ "Child " , "Task" | _ ] } , _child_task_metadata }
1071
+ assert_receive { :event , { :report , % { label: { Task.Supervisor , :terminating } } } , task_metadata }
1072
+ assert_receive { :event , { :report , % { label: { :supervisor , :shutdown } } } , _child_metadata }
1073
+
1074
+ assert_receive { :event , { :report , % { label: { :supervisor , :child_terminated } } } ,
1075
+ _child_task_metadata }
1076
+
1074
1077
assert { :stop , [ _ | _ ] } = task_metadata [ :crash_reason ]
1075
1078
end
1076
1079
@@ -1087,9 +1090,12 @@ defmodule Logger.TranslatorTest do
1087
1090
Start Call: Task.start_link\( Kernel, :exit, \[ :stop\] \)
1088
1091
"""
1089
1092
1090
- assert_receive { :event , { :string , [ "Task " <> _ | _ ] } , task_metadata }
1091
- assert_receive { :event , { :string , [ "Child " | _ ] } , _child_metadata }
1092
- assert_receive { :event , { :string , [ "Child " , "Task" | _ ] } , _child_task_metadata }
1093
+ assert_receive { :event , { :report , % { label: { Task.Supervisor , :terminating } } } , task_metadata }
1094
+ assert_receive { :event , { :report , % { label: { :supervisor , :shutdown } } } , _child_metadata }
1095
+
1096
+ assert_receive { :event , { :report , % { label: { :supervisor , :child_terminated } } } ,
1097
+ _child_task_metadata }
1098
+
1093
1099
assert { :stop , [ _ | _ ] } = task_metadata [ :crash_reason ]
1094
1100
end
1095
1101
@@ -1105,7 +1111,7 @@ defmodule Logger.TranslatorTest do
1105
1111
Start Call: Logger.TranslatorTest.abnormal\( \)
1106
1112
"""
1107
1113
1108
- assert_receive { :event , { :string , [ "Child " | _ ] } , _child_metadata }
1114
+ assert_receive { :event , { :report , % { label: { :supervisor , :shutdown_error } } } , _child_metadata }
1109
1115
end
1110
1116
1111
1117
test "translates Supervisor reports abnormal shutdown on debug" do
@@ -1125,7 +1131,7 @@ defmodule Logger.TranslatorTest do
1125
1131
Type: :worker
1126
1132
"""
1127
1133
1128
- assert_receive { :event , { :string , [ "Child " | _ ] } , _child_metadata }
1134
+ assert_receive { :event , { :report , % { label: { :supervisor , :shutdown_error } } } , _child_metadata }
1129
1135
end
1130
1136
1131
1137
test "translates DynamicSupervisor reports abnormal shutdown" do
@@ -1144,7 +1150,7 @@ defmodule Logger.TranslatorTest do
1144
1150
Start Call: Logger.TranslatorTest.abnormal\( \)
1145
1151
"""
1146
1152
1147
- assert_receive { :event , { :string , [ "Child " | _ ] } , _child_metadata }
1153
+ assert_receive { :event , { :report , % { label: { :supervisor , :shutdown_error } } } , _child_metadata }
1148
1154
end
1149
1155
1150
1156
test "translates DynamicSupervisor reports abnormal shutdown including extra_arguments" do
@@ -1165,7 +1171,7 @@ defmodule Logger.TranslatorTest do
1165
1171
Start Call: Logger.TranslatorTest.abnormal\( :extra, :args\)
1166
1172
"""
1167
1173
1168
- assert_receive { :event , { :string , [ "Child " | _ ] } , _child_metadata }
1174
+ assert_receive { :event , { :report , % { label: { :supervisor , :shutdown_error } } } , _child_metadata }
1169
1175
end
1170
1176
1171
1177
test "translates named DynamicSupervisor reports abnormal shutdown" do
@@ -1184,7 +1190,7 @@ defmodule Logger.TranslatorTest do
1184
1190
Start Call: Logger.TranslatorTest.abnormal\( \)
1185
1191
"""
1186
1192
1187
- assert_receive { :event , { :string , [ "Child " | _ ] } , _child_metadata }
1193
+ assert_receive { :event , { :report , % { label: { :supervisor , :shutdown_error } } } , _child_metadata }
1188
1194
end
1189
1195
1190
1196
test "translates :supervisor_bridge progress" do
@@ -1213,8 +1219,8 @@ defmodule Logger.TranslatorTest do
1213
1219
Start Module: Logger.TranslatorTest.MyBridge
1214
1220
"""
1215
1221
1216
- assert_receive { :event , { :string , [ "Task " <> _ | _ ] } , task_metadata }
1217
- assert_receive { :event , { :string , [ "Child of Supervisor " | _ ] } , _child_metadata }
1222
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , task_metadata }
1223
+ assert_receive { :event , { :report , % { label: { :gen_server , :terminate } } } , _child_metadata }
1218
1224
assert { :stop , [ _ | _ ] } = task_metadata [ :crash_reason ]
1219
1225
end
1220
1226
@@ -1252,9 +1258,11 @@ defmodule Logger.TranslatorTest do
1252
1258
end )
1253
1259
1254
1260
assert log =~ ~s( Start Call: Logger.TranslatorTest.WeirdFunctionNamesGenServer."start link"/?)
1255
- assert_receive { :event , { :string , [ "GenServer " <> _ | _ ] } , server_metadata }
1256
- assert_receive { :event , { :string , [ "Process " | _ ] } , process_metadata }
1257
- assert_receive { :event , { :string , [ "Child " | _ ] } , _child_metadata }
1261
+ assert_receive { :event , { :report , % { label: { :gen_server , :terminate } } } , server_metadata }
1262
+ assert_receive { :event , { :report , % { label: { :proc_lib , :crash } } } , process_metadata }
1263
+
1264
+ assert_receive { :event , { :report , % { label: { :supervisor , :child_terminated } } } ,
1265
+ _child_metadata }
1258
1266
1259
1267
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = server_metadata [ :crash_reason ]
1260
1268
assert { % RuntimeError { message: "oops" } , [ _ | _ ] } = process_metadata [ :crash_reason ]
0 commit comments