-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass_TraceEmitter.hrl
More file actions
2429 lines (1504 loc) · 67.4 KB
/
class_TraceEmitter.hrl
File metadata and controls
2429 lines (1504 loc) · 67.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Copyright (C) 2007-2026 Olivier Boudeville
%
% This file is part of the Ceylan-Traces library.
%
% This library is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License or
% the GNU General Public License, as they are published by the Free Software
% Foundation, either version 3 of these Licenses, or (at your option)
% any later version.
% You can also redistribute it and/or modify it under the terms of the
% Mozilla Public License, version 1.1 or later.
%
% This library is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License and the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License, of the GNU General Public License and of the Mozilla Public License
% along with this library.
% If not, see <http://www.gnu.org/licenses/> and
% <http://www.mozilla.org/MPL/>.
%
% Author: Olivier Boudeville [olivier (dot) boudeville (at) esperide (dot) com]
% Creation date: July 1, 2007.
% If modifying this header, the class_Traceable one may have to be updated in
% turn, as they are counterparts and obey the same logic.
% Note: this header file must be included *after* the WOOPER one, as, in
% production mode, this file has to define functions (namely
% trace_disabled/{1,2,3,4,5}).
% This header centralizes notably all macros related to the sending of traces
% from a class_TraceEmitter.
% See also traces.hrl, for the standalone sending of traces.
-ifndef(class_TraceEmitter_hrl_guard).
-define(class_TraceEmitter_hrl_guard,).
% Allows to set the right emitter categorization, which is the first, childmost
% class of the hierarchy of an instance.
%
% Otherwise this category would have to be explicitly set as an attribute
% afterwards in the constructor (more cumbersome, and any trace sent in-between,
% typically from the constructors of mother classes, would then not bear the
% right emitter category).
%
% As a consequence, each trace-emitting class shall:
%
% - define its emitter categorization, thanks to the
% trace_emitter_categorization define; for example:
% -define( trace_emitter_categorization, "vehicle.car.sedan" ).
%
% - call the trace_categorize/1 macro with the
% class_TraceEmitter:emitter_init/0 construction parameter; for example:
% ?trace_categorize(InstanceName)
%
% See the class_TestTraceEmitter.erl file for an actual example.
%
% Should this macro not be used in a constructor, the actual trace
% categorization will be the first one (if any) set through the upstream
% inheritance. If none of these classes ever set its
% trace_emitter_categorization define, it will be default to the
% default_trace_emitter_categorization one.
%
% -macrospec trace_categorize( emitter_name() | emitter_info() ) ->
% emitter_info().
-define( trace_categorize( TracesInitialisationTermInternal ),
% As few variables bound as possible, and longer variable names chosen
% (prefixed with 'Traces'), to avoid clashes with user-defined variables:
%
case TracesInitialisationTermInternal of
% Emitter categorization already set, just propagate as it is to the
% next mother class.
%
% We have {TraceName, TraceCategorization} here:
{ _, _ } ->
TracesInitialisationTermInternal;
% Expecting here only a string (we are at the level of the actual,
% effective class), it is the place where the emitter categorisation
% shall be introduced.
%
% We just have TracesStandaloneEmitterName here:
_ ->
{ TracesInitialisationTermInternal, ?trace_emitter_categorization }
end ).
% To obtain a proper string-like name, whether a trace categorization has been
% specified or not (typically useful when wanting to designate with '~ts' the
% name of a trace emitter from its constructor, i.e. when its specified name
% (actually, emitter_info()) may still include its trace categorization).
%
% Note that implementing this feature, as opposed to trace_categorize/1 above,
% does not require a macro. Use class_TraceEmitter:get_trace_name/1 instead.
%
% -macrospec trace_name( emitter_name() | emitter_info() ) ->
% emitter_name().
% -define( trace_name( TracesInitialisationTermForNameInternal ),
% % As few variables bound as possible, and longer variable names chosen
% % (prefixed with 'Traces'), to avoid clashes with user-defined variables:
% %
% case TracesInitialisationTermForNameInternal of
% %{ TraceName, _TraceCategorization } ->
% { TraceNameForNameInternal, _ } ->
% TraceNameForNameInternal;
% TraceNameForNameInternal ->
% TraceNameForNameInternal
% end ).
% Conventions section.
% For failure-oriented traces (warning, error, critical, alert and emergency),
% an explicit synchronisation with the trace aggregator is made (plus an echo on
% the console), so that the trace emission is more reliable; as a result it
% becomes itself blocking, for a minimal needed duration (incomparably superior
% to a timer:sleep/1).
%
% That way, even if the very next operation of the process sending such a
% failure-oriented trace is to halt the VM (e.g. with an uncaught throw/1), the
% corresponding trace will be duely recorded and thus available (otherwise such
% critical messages could get lost).
% Technical identifier will be the PID of the trace emitter.
% Name will be the name specified at the creation of the trace emitter.
% EmitterCategorization will the one specified at the creation of the trace
% emitter. It could be deduced from superclasses as well, although it would be
% generally uselessly long and would cause issues in case of multiple
% inheritance.
%
% Call class_TraceEmitter:send_categorized_emitter/* if needing to override the
% trace_emitter_categorization attribute.
% User timestamp will be the current date, as determined by the trace emitter.
% Location will be the current Erlang node, as determined by the trace emitter.
% MessageCategorization will be either specified in the send macro, or
% set the default categorization.
% Following built-in message categorizations are available:
-define( system, "System" ).
-define( management, ?system".Management" ).
-define( application_start, ?management".ExecutionStart" ).
-define( application_resume, ?management".ExecutionResume" ).
-define( application_continue, ?management".ExecutionContinue" ).
-define( application_stop, ?management".ExecutionStop" ).
-define( application_save, ?management".ExecutionSave" ).
-define( application_load, ?management".ExecutionLoad" ).
-define( time, ?system".Time" ).
-define( random, ?system".Random" ).
-define( lifecycle, ?system".Lifecycle" ).
-define( execution, "Execution" ).
-define( update, ?execution".Update" ).
-define( state, ?execution".State" ).
-define( default_message_categorization, ?execution ).
% Severity will be determined from the name of the chosen macro: emergency,
% alert, critical, error, warning, notice, info or debug (or void).
% Message will be directly specified in the macro call.
-ifndef(trace_emitter_categorization).
-define( trace_emitter_categorization, "Traces.Uncategorized" ).
-endif. % trace_emitter_categorization
% Section dedicated to trace emitters that are not WOOPER-based and are
% dedicated to tests.
%
% See also: test_constructs.hrl.
% When no emitter is specified:
-define( default_test_emitter_categorization, "Test" ).
-define( default_case_emitter_categorization, "Case" ).
-define( default_standalone_emitter_categorization, "Standalone" ).
-define( default_trace_emitter_categorization, "uncategorized" ).
% For messages, we may use either strings or atoms (that is the most compact
% repeated form):
%
-define( default_test_message_categorization, 'test' ).
% Section dedicated to trace emitters that are not WOOPER-based and are
% dedicated to cases.
%
% See also: case_constructs.hrl.
%
-define( default_case_message_categorization, 'case' ).
% Section dedicated to trace emitters that are not WOOPER-based and dedicated to
% classical functions (as opposed to methods from class_TraceEmitter).
%
% See also: traces.hrl.
-define( default_standalone_message_categorization, 'standalone' ).
% We moved away from the tracing_activated conditional sections the most severe
% trace sendings (namely emergency, alert, critical, error and warning), as in
% all cases (whether or not the traces are activated), we want them, and both as
% actual traces and as console outputs, as they should not be missed.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Emergency section.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Subsection for Emergency, without formatting.
% Plain, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'emergency' type with specified parameters and an explicit
% state.
%
-define( send_emergency( State, Message ),
class_TraceEmitter:send_safe( emergency, State, Message )
).
% Sends a trace of 'emergency' type with specified parameters and implicit use
% of a variable named 'State'.
%
-define( emergency( Message ),
class_TraceEmitter:send_safe( emergency, State, Message )
).
% Categorized, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'emergency' type with specified parameters and an explicit
% state.
%
-define( send_emergency_cat( State, Message, MessageCategorization ),
class_TraceEmitter:send_safe( emergency, State, Message,
MessageCategorization )
).
% Sends a trace of 'emergency' type with specified parameters and implicit use
% of a variable named 'State'.
%
-define( emergency_cat( Message, MessageCategorization ),
class_TraceEmitter:send_safe( emergency, State, Message,
MessageCategorization )
).
% Categorized with application-specific timestamp, with 2 variations regarding
% state: explicit or implicit.
% Sends a trace of 'emergency' type with specified parameters and an explicit
% state.
%
-define( send_emergency_full( State, Message, MessageCategorization,
ApplicationTimestamp ),
class_TraceEmitter:send_safe( emergency, State, Message,
MessageCategorization, ApplicationTimestamp )
).
% Sends a trace of 'emergency' type with specified parameters and implicit use
% of a variable named 'State'.
%
-define( emergency_full( Message, MessageCategorization, ApplicationTimestamp ),
class_TraceEmitter:send_safe( emergency, State, Message,
MessageCategorization, ApplicationTimestamp )
).
% Subsection for Emergency, with formatting.
% Plain, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'emergency' type (echoed on the console) with specified
% parameters and an explicit state.
%
-define( send_emergency_fmt( State, Message, FormatValues ),
class_TraceEmitter:send_safe( emergency, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'emergency' type with specified parameters and an explicit
% state, with no console echo (message just recorded in the traces).
%
-define( send_emergency_no_echo_fmt( State, Message, FormatValues ),
class_TraceEmitter:send_synchronised( emergency, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'emergency' type (echoed on the console) with specified
% parameters and implicit use of a variable named 'State'.
%
-define( emergency_fmt( Message, FormatValues ),
class_TraceEmitter:send_safe( emergency, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'emergency' type with specified parameters and implicit use
% of a variable named 'State', with no console echo (message just recorded in
% the traces).
%
-define( emergency_no_echo_fmt( Message, FormatValues ),
class_TraceEmitter:send_synchronised( emergency, State,
text_utils:format( Message, FormatValues ) )
).
% Categorized, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'emergency' type with specified parameters and an explicit
% state.
%
-define( send_emergency_fmt_cat( State, Message, FormatValues,
MessageCategorization ),
class_TraceEmitter:send_safe( emergency, State,
text_utils:format( Message, FormatValues ), MessageCategorization )
).
% Sends a trace of 'emergency' type with specified parameters and implicit use
% of a variable named 'State'.
%
-define( emergency_fmt_cat( Message, FormatValues, MessageCategorization ),
class_TraceEmitter:send_safe( emergency, State,
text_utils:format( Message, FormatValues ), MessageCategorization )
).
% Categorized with application timestamp, with 2 variations regarding state:
% explicit or implicit.
% Sends a trace of 'emergency' type with specified parameters and an explicit
% state.
%
-define( send_emergency_fmt_full( State, Message, FormatValues,
MessageCategorization, ApplicationTimestamp ),
class_TraceEmitter:send_safe( emergency, State,
text_utils:format( Message, FormatValues ),
MessageCategorization, ApplicationTimestamp )
).
% Sends a trace of 'emergency' type with specified parameters and implicit use
% of a variable named 'State'.
%
-define( emergency_fmt_full( Message, FormatValues, MessageCategorization,
ApplicationTimestamp ),
class_TraceEmitter:send_safe( emergency, State,
text_utils:format( Message, FormatValues ),
MessageCategorization, ApplicationTimestamp )
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Alert section.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Subsection for Alert, without formatting.
% Plain, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'alert' type with specified parameters and an explicit state.
-define( send_alert( State, Message ),
class_TraceEmitter:send_safe( alert, State, Message )
).
% Sends a trace of 'alert' type with specified parameters and implicit use of a
% variable named 'State'.
%
-define( alert( Message ),
class_TraceEmitter:send_safe( alert, State, Message )
).
% Categorized, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'alert' type with specified parameters and an explicit state.
-define( send_alert_cat( State, Message, MessageCategorization ),
class_TraceEmitter:send_safe( alert, State, Message,
MessageCategorization )
).
% Sends a trace of 'alert' type with specified parameters and implicit use of a
% variable named 'State'.
%
-define( alert_cat( Message, MessageCategorization ),
class_TraceEmitter:send_safe( alert, State, Message,
MessageCategorization )
).
% Categorized with application-specific timestamp, with 2 variations regarding
% state: explicit or implicit.
% Sends a trace of 'alert' type with specified parameters and an explicit state.
-define( send_alert_full( State, Message, MessageCategorization,
ApplicationTimestamp ),
class_TraceEmitter:send_safe( alert, State, Message,
MessageCategorization, ApplicationTimestamp )
).
% Sends a trace of 'alert' type with specified parameters and implicit use of a
% variable named 'State'.
%
-define( alert_full( Message, MessageCategorization, ApplicationTimestamp ),
class_TraceEmitter:send_safe( alert, State, Message,
MessageCategorization, ApplicationTimestamp )
).
% Subsection for Alert, with formatting.
% Plain, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'alert' type (echoed on the console) with specified
% parameters and an explicit state.
%
-define( send_alert_fmt( State, Message, FormatValues ),
class_TraceEmitter:send_safe( alert, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'alert' type with specified parameters and an explicit state,
% with no console echo (message just recorded in the traces).
%
-define( send_alert_no_echo_fmt( State, Message, FormatValues ),
class_TraceEmitter:send_synchronised( alert, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'alert' type (echoed on the console) with specified
% parameters and implicit use of a variable named 'State'.
%
-define( alert_fmt( Message, FormatValues ),
class_TraceEmitter:send_safe( alert, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'alert' type with specified parameters and implicit use of a
% variable named 'State', with no console echo (message just recorded in the
% traces).
%
-define( alert_no_echo_fmt( Message, FormatValues ),
class_TraceEmitter:send_synchronised( alert, State,
text_utils:format( Message, FormatValues ) )
).
% Categorized, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'alert' type with specified parameters and an explicit state.
-define( send_alert_fmt_cat( State, Message, FormatValues,
MessageCategorization ),
class_TraceEmitter:send_safe( alert, State,
text_utils:format( Message, FormatValues ), MessageCategorization )
).
% Sends a trace of 'alert' type with specified parameters and implicit use of a
% variable named 'State'.
%
-define( alert_fmt_cat( Message, FormatValues, MessageCategorization ),
class_TraceEmitter:send_safe( alert, State,
text_utils:format( Message, FormatValues ), MessageCategorization )
).
% Categorized with application timestamp, with 2 variations regarding state:
% explicit or implicit.
% Sends a trace of 'alert' type with specified parameters and an explicit state.
-define( send_alert_fmt_full( State, Message, FormatValues,
MessageCategorization, ApplicationTimestamp ),
class_TraceEmitter:send_safe( alert, State,
text_utils:format( Message, FormatValues ),
MessageCategorization, ApplicationTimestamp )
).
% Sends a trace of 'alert' type with specified parameters and implicit use of a
% variable named 'State'.
%
-define( alert_fmt_full( Message, FormatValues, MessageCategorization,
ApplicationTimestamp ),
class_TraceEmitter:send_safe( alert, State,
text_utils:format( Message, FormatValues ),
MessageCategorization, ApplicationTimestamp )
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Critical section.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Subsection for Critical, without formatting.
% Plain, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'critical' type with specified parameters and an explicit
% state.
%
-define( send_critical( State, Message ),
class_TraceEmitter:send_safe( critical, State, Message )
).
% Sends a trace of 'critical' type with specified parameters and implicit use of
% a variable named 'State'.
%
-define( critical( Message ),
class_TraceEmitter:send_safe( critical, State, Message )
).
% Categorized, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'critical' type with specified parameters and an explicit
% state.
%
-define( send_critical_cat( State, Message, MessageCategorization ),
class_TraceEmitter:send_safe( critical, State, Message,
MessageCategorization )
).
% Sends a trace of 'critical' type with specified parameters and implicit use of
% a variable named 'State'.
%
-define( critical_cat( Message, MessageCategorization ),
class_TraceEmitter:send_safe( critical, State, Message,
MessageCategorization )
).
% Categorized with application-specific timestamp, with 2 variations regarding
% state: explicit or implicit.
% Sends a trace of 'critical' type with specified parameters and an explicit
% state.
%
-define( send_critical_full( State, Message, MessageCategorization,
ApplicationTimestamp ),
class_TraceEmitter:send_safe( critical, State, Message,
MessageCategorization, ApplicationTimestamp )
).
% Sends a trace of 'critical' type with specified parameters and implicit use of
% a variable named 'State'.
%
-define( critical_full( Message, MessageCategorization, ApplicationTimestamp ),
class_TraceEmitter:send_safe( critical, State, Message,
MessageCategorization, ApplicationTimestamp )
).
% Subsection for Critical, with formatting.
% Plain, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'critical' type (echoed on the console) with specified
% parameters and an explicit state.
%
-define( send_critical_fmt( State, Message, FormatValues ),
class_TraceEmitter:send_safe( critical, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'critical' type with specified parameters and an explicit
% state, with no console echo (message just recorded in the traces).
%
-define( send_critical_no_echo_fmt( State, Message, FormatValues ),
class_TraceEmitter:send_synchronised( critical, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'critical' type (echoed on the console) with specified
% parameters and implicit use of a variable named 'State'.
%
-define( critical_fmt( Message, FormatValues ),
class_TraceEmitter:send_safe( critical, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'critical' type with specified parameters and implicit use of
% a variable named 'State', with no console echo (message just recorded in the
% traces).
%
-define( critical_no_echo_fmt( Message, FormatValues ),
class_TraceEmitter:send_synchronised( critical, State,
text_utils:format( Message, FormatValues ) )
).
% Categorized, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'critical' type with specified parameters and an explicit
% state.
%
-define( send_critical_fmt_cat( State, Message, FormatValues,
MessageCategorization ),
class_TraceEmitter:send_safe( critical, State,
text_utils:format( Message, FormatValues ), MessageCategorization )
).
% Sends a trace of 'critical' type with specified parameters and implicit use of
% a variable named 'State'.
%
-define( critical_fmt_cat( Message, FormatValues, MessageCategorization ),
class_TraceEmitter:send_safe( critical, State,
text_utils:format( Message, FormatValues ), MessageCategorization )
).
% Categorized with application timestamp, with 2 variations regarding state:
% explicit or implicit.
% Sends a trace of 'critical' type with specified parameters and an explicit
% state.
%
-define( send_critical_fmt_full( State, Message, FormatValues,
MessageCategorization, ApplicationTimestamp ),
class_TraceEmitter:send_safe( critical, State,
text_utils:format( Message, FormatValues ),
MessageCategorization, ApplicationTimestamp )
).
% Sends a trace of 'critical' type with specified parameters and implicit use of
% a variable named 'State'.
%
-define( critical_fmt_full( Message, FormatValues, MessageCategorization,
ApplicationTimestamp ),
class_TraceEmitter:send_safe( critical, State,
text_utils:format( Message, FormatValues ),
MessageCategorization, ApplicationTimestamp )
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Error section.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Subsection for Error, without formatting.
% Plain, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'error' type with specified parameters and an explicit state.
-define( send_error( State, Message ),
class_TraceEmitter:send_safe( error, State, Message )
).
% Sends a trace of 'error' type with specified parameters and implicit use of a
% variable named 'State'.
%
-define( error( Message ),
class_TraceEmitter:send_safe( error, State, Message )
).
% Sends a trace of 'error' type with specified parameters and implicit use of a
% variable named 'State', with no console echo (message just recorded in the
% traces).
%
-define( error_no_echo_fmt( Message ),
class_TraceEmitter:send_synchronised( error, State, Message ) )
).
% Categorized, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'error' type with specified parameters and an explicit state.
-define( send_error_cat( State, Message, MessageCategorization ),
class_TraceEmitter:send_safe( error, State,
text_utils:format( Message, FormatValues ), MessageCategorization )
).
% Sends a trace of 'error' type with specified parameters and implicit use of a
% variable named 'State'.
%
-define( error_cat( Message, MessageCategorization ),
class_TraceEmitter:send_safe( error, State, Message,
MessageCategorization )
).
% Categorized with application timestamp, with 2 variations regarding state:
% explicit or implicit.
% Sends a trace of 'error' type with specified parameters and an explicit state.
-define( send_error_full( State, Message, MessageCategorization,
ApplicationTimestamp ),
class_TraceEmitter:send_safe( error, State, Message,
MessageCategorization, ApplicationTimestamp )
).
% Sends a trace of 'error' type with specified parameters and implicit use of a
% variable named 'State'.
%
-define( error_full( Message, MessageCategorization, ApplicationTimestamp ),
class_TraceEmitter:send_safe( error, State, Message,
MessageCategorization, ApplicationTimestamp )
).
% Subsection for Error, with formatting.
% Plain, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'error' type (echoed on the console) with specified
% parameters and an explicit state.
%
-define( send_error_fmt( State, Message, FormatValues ),
class_TraceEmitter:send_safe( error, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'error' type with specified parameters and an explicit
% state, with no console echo (message just recorded in the
% traces).
%
-define( send_error_no_echo_fmt( State, Message, FormatValues ),
class_TraceEmitter:send_synchronised( error, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'error' type (echoed on the console) with specified
% parameters and implicit use of a variable named 'State'.
%
-define( error_fmt( Message, FormatValues ),
class_TraceEmitter:send_safe( error, State,
text_utils:format( Message, FormatValues ) )
).
% Sends a trace of 'error' type with specified parameters and implicit use of a
% variable named 'State', with no console echo (message just recorded in the
% traces).
%
-define( error_no_echo_fmt( Message, FormatValues ),
class_TraceEmitter:send_synchronised( error, State,
text_utils:format( Message, FormatValues ) )
).
% Categorized, with 2 variations regarding state: explicit or implicit.
% Sends a trace of 'error' type with specified parameters and an explicit state.
-define( send_error_fmt_cat( State, Message, FormatValues,
MessageCategorization ),
class_TraceEmitter:send_safe( error, State,
text_utils:format( Message, FormatValues ),
MessageCategorization )
).
% Sends a trace of 'error' type with specified parameters and implicit use of a
% variable named 'State'.
%
-define( error_fmt_cat( Message, FormatValues, MessageCategorization ),
class_TraceEmitter:send_safe( error, State,
text_utils:format( Message, FormatValues ),
MessageCategorization )
).
% Categorized with application timestamp, with 2 variations regarding state:
% explicit or implicit.
% Sends a trace of 'error' type with specified parameters and an explicit state.
-define( send_error_fmt_full( State, Message, FormatValues,
MessageCategorization, ApplicationTimestamp ),
class_TraceEmitter:send_safe( error, State,
text_utils:format( Message, FormatValues ),
MessageCategorization, ApplicationTimestamp )
).
% Sends a trace of 'error' type with specified parameters and implicit use of a
% variable named 'State'.
%
-define( error_fmt_full( Message, FormatValues, MessageCategorization,
ApplicationTimestamp ),
class_TraceEmitter:send_safe( error, State,
text_utils:format( Message, FormatValues ),
MessageCategorization, ApplicationTimestamp )
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Warning section.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Subsection for Warning, without formatting.
% When not in debug mode (like here), one may or may not want warning messages
% to be echoed in the console (as are the messages with the error, critical,
% etc. severities). By default they are echoed (better safe than sorry).
%
% Swap the display_warning/{1,2} implementations as preferred (and recompile):