forked from blikblum/multilog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultilog.pas
1905 lines (1549 loc) · 79.1 KB
/
multilog.pas
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
unit MultiLog;
{
Main unit of the Multilog logging system.
author of original MultiLog: Luiz Américo Pereira Câmara; pascalive@bol.com.br
nb: all units are encoded with UTF-8 without BOM, using EDI "file settings\encoding\UTF-8" contextual menu.
Copyright (C) 2006 Luiz Américo Pereira Câmara
pascalive@bol.com.br
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
This program 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 Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
{$ifdef fpc}
{$mode objfpc}{$H+}
{$endif}
interface
uses
{$ifndef fpc}Types, fpccompat,{$endif} Classes, SysUtils, syncobjs, math, TypInfo;
{$Include multilog_user1.inc}
type
TIntegratedLogger = class;
TMethodToLog = methInfo..methClear;
{$Include multilog_user2.inc}
TGroupOfForWhatReasonsToLogActually = Set of TForWhichTrackingPurpose;
{$Include multilog_user3.inc}
lwNone = [];
type
TrecLogMessage = record
iMethUsed: Integer;
dtMsgTime: TDateTime;
sMsgText: String;
pData: TStream;
setFilterDynamic: TGroupOfForWhatReasonsToLogActually;
end;
TCustomDataNotify = function (Sender: TIntegratedLogger; Data: Pointer; var DoSend: Boolean): String of Object;
TCustomDataNotifyStatic = function (Sender: TIntegratedLogger; Data: Pointer; var DoSend: Boolean): String;
{ TLogChannelUtils }
TLogChannelUtils = class
class function SetofToInt(const aSetOf: TGroupOfForWhatReasonsToLogActually): integer;
class function IntToSetof(const aSetof: Integer): TGroupOfForWhatReasonsToLogActually;
class function SetofToString(const aSetOf: TGroupOfForWhatReasonsToLogActually): string;
class function StringToSetof(const aSetOf: string): Integer;
class function CountElements(const aSetOf: TGroupOfForWhatReasonsToLogActually): integer;
end;
{ TLogChannel }
TLogChannel = class
private
FbActive: Boolean;
protected
FbShowTime: Boolean;
FbShowPrefixMethod: Boolean;
FbShow_DynamicFilter_forWhatReasonsToLogActually: Boolean;
public
procedure SetShowTime(const AValue: Boolean); virtual;
procedure Set_ShowFilterDynamic_forWhatReasonsToLogActually(AValue: Boolean); virtual;
procedure Clear; virtual; abstract;
procedure Deliver(const AMsg: TrecLogMessage); virtual; abstract;
procedure Init; virtual;
property Active: Boolean read FbActive write FbActive;
property ShowTime: boolean read FbShowTime write SetShowTime;
property ShowPrefixMethod: Boolean read FbShowPrefixMethod write FbShowPrefixMethod;
property ShowDynamicFilter_forWhatReasonsToLogActually: Boolean read FbShow_DynamicFilter_forWhatReasonsToLogActually write Set_ShowFilterDynamic_forWhatReasonsToLogActually;
end;
{ TChannelList }
TChannelList = class
private
FoList: TFpList;
function GetCount: Integer; {$ifdef fpc}inline;{$endif}
function GetItems(AIndex: Integer): TLogChannel; {$ifdef fpc}inline;{$endif}
public
constructor Create;
destructor Destroy; override;
function Add(AChannel: TLogChannel):Integer;
procedure Remove(AChannel:TLogChannel);
property Count: Integer read GetCount;
property Items[AIndex:Integer]: TLogChannel read GetItems; default;
end;
{ TIntegratedLogger }
TIntegratedLogger = class
private
FiMaxStackCount: Integer;
FoChannels: TChannelList;
FoLogStack: TStrings;
FoCheckList: TStringList;
FoCounterList: TStringList;
FOnCustomData: TCustomDataNotify;
FsetFilterDynamic_forWhatReasonsToLogActually: TGroupOfForWhatReasonsToLogActually;
class var FoDefaultChannels: TChannelList;
procedure GetCallStack(AStream:TStream);
class function GetDefaultChannels: TChannelList; static;
function GetEnabled: Boolean;
procedure SetMaxStackCount(const AValue: Integer);
procedure SetThreadSafe;
protected
procedure SendStream(AMethodUsed: Integer; const AText: String; o_AStream: TStream);
procedure SendBuffer(AMethodUsed: Integer; const AText: String; var pBuffer; Count: LongWord);
procedure SetFilterDynamic_forWhatReasonsToLogActually(AValue: TGroupOfForWhatReasonsToLogActually);
public
constructor Create;
destructor Destroy; override;
function CalledBy(const AMethodName: String): Boolean;
procedure Clear;
//Helper functions
function RectToStr(const ARect: TRect): String; //inline
function PointToStr(const APoint: TPoint): String; //inline
//Send functions: for backward compatibility. SendInfo have been introduced in order to be harmonized with SendError and SendWarning
procedure Send(const AText: String); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String); overload;
procedure Send(const AText: String; Args: array of const); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; Args: array of const); overload;
procedure Send(const AText, AValue: String); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText,AValue: String); overload;
procedure Send(const AText: String; AValue: Integer); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Integer); overload;
{$ifdef fpc}
procedure Send(const AText: String; AValue: Cardinal); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Cardinal); overload;
{$endif}
procedure Send(const AText: String; AValue: Double); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Double); overload;
procedure Send(const AText: String; AValue: Int64); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Int64); overload;
procedure Send(const AText: String; AValue: QWord); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: QWord); overload;
procedure Send(const AText: String; AValue: Boolean); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Boolean); overload;
procedure Send(const AText: String; const ARect: TRect); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; const ARect: TRect); overload;
procedure Send(const AText: String; const APoint: TPoint); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; const APoint: TPoint); overload;
{ Explanations: whe log with a methTStrings's method.}
procedure Send(const AText: String; AStrList: TStrings); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; o_AStrList: TStrings); overload;
{ Explanations: whe log with a methObject's method.}
procedure Send(const AText: String; AObject: TObject); overload;
procedure Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AObject: TObject); overload;
{ Explanations: whe log with a methInfo's method.}
procedure SendInfo(const AText: String); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String); overload;
procedure SendInfo(const AText: String; Args: array of const); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; Args: array of const); overload;
procedure SendInfo(const AText, AValue: String); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText,AValue: String); overload;
procedure SendInfo(const AText: String; AValue: Integer);
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Integer); overload;
{$ifdef fpc}
procedure SendInfo(const AText: String; AValue: Cardinal); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Cardinal); overload;
{$endif}
procedure SendInfo(const AText: String; AValue: Double); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Double); overload;
procedure SendInfo(const AText: String; AValue: Int64); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Int64); overload;
procedure SendInfo(const AText: String; AValue: QWord); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: QWord); overload;
procedure SendInfo(const AText: String; AValue: Boolean); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Boolean); overload;
procedure SendInfo(const AText: String; const ARect: TRect); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; const ARect: TRect); overload;
procedure SendInfo(const AText: String; const APoint: TPoint); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; const APoint: TPoint); overload;
{ Explanations: whe log with a methTStrings's method.}
procedure SendInfo(const AText: String; AStrList: TStrings); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; o_AStrList: TStrings); overload;
{ Explanations: whe log with a methObject's method.}
procedure SendInfo(const AText: String; AObject: TObject); overload;
procedure SendInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AObject: TObject); overload;
{ Explanations: whe log with a methValue's method.}
procedure SendPointer(const AText: String; APointer: Pointer); overload;
procedure SendPointer(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; APointer: Pointer); overload;
{ Explanations: whe log with a methCallStack's method.}
procedure SendCallStack(const AText: String); overload;
procedure SendCallStack(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String); overload;
{ Explanations: whe log with a methException's method.}
procedure SendException(const AText: String; AException: Exception); overload;
procedure SendException(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AException: Exception); overload;
{ Explanations: check Exception hierarchy (ultimate ancestor=EDatabaseError || EStreamError || ...), to grab its specific fields into a dumped string.}
function GetDescriptionOfSQLException (AException: Exception): string;
{ Explanations: whe log with a methHeapInfo's method.}
procedure SendHeapInfo(const AText: String); overload;
procedure SendHeapInfo(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String);overload;
{ Explanations: whe log with a methMemory's method.}
procedure SendMemory(const AText: String; Address: Pointer; Size: LongWord; Offset: Integer = 0); overload;
procedure SendMemory(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; pAddress: Pointer; iSize: LongWord; iOffset: Integer = 0); overload;
{ Explanations: whe log with a methConditional's method.}
procedure SendIf(const AText: String; Expression: Boolean); overload;
procedure SendIf(Classes: TGroupOfForWhatReasonsToLogActually; const AText: String; Expression: Boolean); overload;
procedure SendIf(const AText: String; Expression, IsTrue: Boolean); overload;
procedure SendIf(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; bExpression, bIsTrue: Boolean); overload;
{ Explanations: whe log with a ltWarning's method.}
procedure SendWarning(const AText: String); overload;
procedure SendWarning(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String); overload;
{ Explanations: whe log with a ltError's method.}
procedure SendError(const AText: String); overload;
procedure SendError(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String); overload;
{ Explanations: whe log with a methCustomData's method.}
procedure SendCustomData(const AText: String; Data: Pointer); overload;
procedure SendCustomData(const AText: String; Data: Pointer; CustomDataFunction: TCustomDataNotify); overload;
procedure SendCustomData(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; Data: Pointer; CustomDataFunction: TCustomDataNotify); overload;
procedure SendCustomData(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; Data: Pointer); overload;
procedure SendCustomData(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; Data: Pointer; CustomDataFunction: TCustomDataNotifyStatic); overload;
procedure SendCustomData(const AText: String; Data: Pointer; CustomDataFunction: TCustomDataNotifyStatic); overload;
{ Explanations: whe log with a methCheckpoint's method.}
procedure AddCheckPoint; overload;
procedure AddCheckPoint(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually); overload;
procedure AddCheckPoint(const sCheckName: String); overload;
procedure AddCheckPoint(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const sCheckName: String); overload;
{ Explanations: whe log with a methCounter's method.}
procedure IncCounter(const sCounterName: String); overload;
procedure IncCounter(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const CounterName: String); overload;
{ Explanations: whe log with a methCounter's method.}
procedure DecCounter(const sCounterName: String); overload;
procedure DecCounter(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const CounterName: String); overload;
{ Explanations: whe log with a methCounter's method.}
procedure ResetCounter(const sCounterName: String); overload;
procedure ResetCounter(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const CounterName: String); overload;
{ Explanations: get pointer on FoCounterList.Objects[CounterName].}
function GetCounter(const CounterName: String): Integer; overload;
{ Explanations: whe log with a methCheckpoint's method.}
procedure ResetCheckPoint; overload;
procedure ResetCheckPoint(Classes: TGroupOfForWhatReasonsToLogActually); overload;
procedure ResetCheckPoint(const sCheckName: String); overload;
procedure ResetCheckPoint(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually;const CheckName: String); overload;
{ Explanations: whe log with a methEnterMethod's method.}
procedure EnterMethod(const AMethodName: String; const AMessage: String = ''); overload;
procedure EnterMethod(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AMethodName: String; const AMessage: String = ''); overload;
procedure EnterMethod(Sender: TObject; const AMethodName: String; const AMessage: String = ''); overload;
procedure EnterMethod(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; Sender: TObject; const AMethodName: String; const AMessage: String = ''); overload;
{ Explanations: whe log with a methExitMethod's method.}
procedure ExitMethod(const AMethodName: String; const AMessage: String = ''); overload;
procedure ExitMethod(Sender: TObject; const AMethodName: String; const AMessage: String = ''); overload;
procedure ExitMethod(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AMethodName: String; const AMessage: String = ''); overload;
procedure ExitMethod({%H-}aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; Sender: TObject; const AMethodName: String; const AMessage: String = ''); overload;
{ Explanations: whe log with a methWatch's method.}
procedure Watch(const AText, AValue: String); overload;
procedure Watch(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText,AValue: String); overload;
procedure Watch(const AText: String; AValue: Integer); overload;
procedure Watch(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Integer); overload;
{$ifdef fpc}
procedure Watch(const AText: String; AValue: Cardinal); overload;
procedure Watch(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Cardinal); overload;
{$endif}
procedure Watch(const AText: String; AValue: Double); overload;
procedure Watch(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Double); overload;
procedure Watch(const AText: String; AValue: Boolean); overload;
procedure Watch(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Boolean); overload;
{ Explanations: whe log with a methSubEventBetweenEnterAndExitMethods's method.}
procedure SubEventBetweenEnterAndExitMethods(const AText: String); overload;
procedure SubEventBetweenEnterAndExitMethods(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String); overload;
class property DefaultChannels: TChannelList read GetDefaultChannels;
{ public field that contains the filter set which is intersected with the *possible* tracking purposes =~ ..."pass-filter"'s set, blocking or not the logging. }
property FilterDynamic_forWhatReasonsToLogActually: TGroupOfForWhatReasonsToLogActually read FsetFilterDynamic_forWhatReasonsToLogActually write SetFilterDynamic_forWhatReasonsToLogActually;
property Channels: TChannelList read FoChannels;
property LogStack: TStrings read FoLogStack;
property MaxStackCount: Integer read FiMaxStackCount write SetMaxStackCount;
property OnCustomData: TCustomDataNotify read FOnCustomData write FOnCustomData;
end;
{ TLogChannelWrapper }
TLogChannelWrapper = class(TComponent)
private
FoChannel: TLogChannel;
protected
{ Explanations: if AComponent - a specialized channel, like TMemoChannel - is in a @code(TComponentState = [opRemove]),
and if there's a AComponent's FChannelWrapper that is memory managed by AComponent,
then this FChannelWrapper must stop immediately any activity.}
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
property Channel: TLogChannel read FoChannel write FoChannel;
end;
TFixedCriticalSection = class(TCriticalSection)
private
{$WARN 5029 off : Private field "$1.$2" is never used} // FDummy not used anywhere so switch off such warnings
FDummy: array [0..95] of Byte; // fix multiprocessor cache safety http://blog.synopse.info/post/2016/01/09/Safe-locks-for-multi-thread-applications
end;
TGuardian = TFixedCriticalSection;
var
goLogger: TIntegratedLogger;
implementation
uses
db;
const
DefaultCheckName = 'CheckPoint';
function FormatNumber(iValue: Integer):String;
var
sTempStr: String;
i, iDigits: Integer;
begin
iDigits:= 0;
Result:= '';
sTempStr:= IntToStr(iValue);
for i := length(sTempStr) downto 1 do begin
//todo: implement using mod() -> get rids of iDigits
if iDigits = 3 then begin
iDigits:=0;
Result:= DefaultFormatSettings.ThousandSeparator+Result;
end;
Result:= sTempStr[i]+Result;
Inc(iDigits);
end;
end;
{ Explanations: global procedure returns the literal description of the "sender" component that is at the origin of the event.}
function GetObjectDescription(Sender: TObject): String;
begin
Result:= Sender.ClassName;
if (Sender is TComponent) and (TComponent(Sender).Name <> '') then
Result := Result + '(' + TComponent(Sender).Name + ')';
end;
var
goGuardian: TGuardian;
{ TLogChannelUtils }
class function TLogChannelUtils.SetofToInt(const aSetOf: TGroupOfForWhatReasonsToLogActually): integer;
begin
Result:= Integer(aSetOf); // Beware: Cf. [*]
end;
class function TLogChannelUtils.IntToSetof(const aSetof: Integer): TGroupOfForWhatReasonsToLogActually;
begin
result:= TGroupOfForWhatReasonsToLogActually(aSetof); // Beware: Cf. [*]
end;
class function TLogChannelUtils.SetofToString(const aSetOf: TGroupOfForWhatReasonsToLogActually): string;
begin
Result:= TypInfo.SetToString(PTypeInfo(TypeInfo(TGroupOfForWhatReasonsToLogActually)), Integer(aSetOf), true);
end;
class function TLogChannelUtils.StringToSetof(const aSetOf: string): Integer;
begin
Result:= TypInfo.StringToSet(PTypeInfo(TypeInfo(TGroupOfForWhatReasonsToLogActually)),aSetOf);
end;
class function TLogChannelUtils.CountElements(const aSetOf: TGroupOfForWhatReasonsToLogActually): integer;
var
k: TForWhichTrackingPurpose;
begin
Result:= 0;
for k:= lwDebug to lwLast do begin
if k in aSetOf then
Result:= Result+1;
end;
end;
{ TIntegratedLogger }
procedure TIntegratedLogger.GetCallStack(AStream: TStream);
{$ifdef fpc}
var
i: Longint;
prevbp: Pointer;
caller_frame,
caller_addr,
bp: Pointer;
S: String;
{$endif}
begin
{$ifdef fpc}
//routine adapted from fpc source
//This trick skip SendCallstack item
//bp:=get_frame; //get_frame=IP's frame
bp:= get_caller_frame(get_frame); //BP = number of the current base frame
try
prevbp:=bp-1; //prev_BP = number of the precedent base frame *)
i:=0;
//is_dev:=do_isdevice(textrec(f).Handle);
while bp > prevbp Do // while we can pop...
begin
caller_addr := get_caller_addr(bp); //we get the IP's caller
caller_frame := get_caller_frame(bp); //and its BP
if (caller_addr=nil) then
break; //We are back at the start point: all has been "poped"
//todo: see what is faster concatenate string and use writebuffer or current
S:=BackTraceStrFunc(caller_addr)+LineEnding; //EI name
AStream.WriteBuffer(S[1],Length(S));
Inc(i);
if (i>=FiMaxStackCount) or (caller_frame=nil) then
break;
prevbp:=bp; //previous variable is set with the IP
bp:=caller_frame; //the IP becomes the courent caller of the courrent frame: we backward from one call frame
end;
except
{ prevent endless dump if an exception occured }
end;
{$endif}
end;
{^^ Explanations:
When FsetFilterDynamic_forWhatReasonsToLogActually is changed by the calling programm, character ° is logged twice: here and internally in goLogger.SendStream.
^^}
procedure TIntegratedLogger.SetFilterDynamic_forWhatReasonsToLogActually(AValue: TGroupOfForWhatReasonsToLogActually);
begin
if FsetFilterDynamic_forWhatReasonsToLogActually=AValue then Exit;
goLogger.SendInfo('°');
FsetFilterDynamic_forWhatReasonsToLogActually:= AValue;
end;
class function TIntegratedLogger.GetDefaultChannels: TChannelList;
begin
if FoDefaultChannels = nil then
FoDefaultChannels := TChannelList.Create;
Result := FoDefaultChannels;
end;
function TIntegratedLogger.GetEnabled: Boolean;
begin
Result:= FsetFilterDynamic_forWhatReasonsToLogActually <> [];
end;
procedure DispatchLogMessage(o_Channels: TChannelList; const Msg: TrecLogMessage);
var
i: Integer;
o_Channel: TLogChannel;
begin
for i := 0 to o_Channels.Count - 1 do begin
o_Channel := o_Channels[i];
if o_Channel.Active then
o_Channel.Deliver(Msg);
end;
end;
procedure TIntegratedLogger.SendStream(AMethodUsed: Integer; const AText: String; o_AStream: TStream);
var
recMsg: TrecLogMessage;
{^^ Explanations:
création d'un record dans le même ordre que sa déclaration en pense-bête...,
...car surtout, s'il est envoyé en IPC et lu depuis un autre programme, la mémoire devra le relire dans cet ordre,
en utilisant TLogChannelUtils pour encoder et décoder le champ SetOf du record-TrecLogMessage.
^^}
procedure CreateMsg;
begin
with recMsg do begin
iMethUsed:= AMethodUsed;
dtMsgTime:= Now;
sMsgText:= AText;
pData:= o_AStream;
end;
if (AMethodUsed = methSubEventBetweenEnterAndExitMethods) then begin
recMsg.setFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually + [lwStudyChainedEvents];
recMsg.sMsgText:= recMsg.sMsgText; // as a reminder of the unbreakable association betweeb some methode names and their homonymous group
end
else if (AMethodUsed = methEnterMethod) or (AMethodUsed = methExitMethod) then begin
recMsg.setFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually + [lwStudyChainedEvents, lwEvents];
recMsg.sMsgText:= recMsg.sMsgText; // as a reminder of the unbreakable association betweeb some methode names and their homonymous group
end
else if (AMethodUsed = methError) or ((AMethodUsed = methException)) then begin
recMsg.setFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually + [lwError];
recMsg.sMsgText:= recMsg.sMsgText; // as a reminder of the unbreakable association betweeb some methode names and their homonymous group
end
else if (AMethodUsed = methWarning) then begin
recMsg.setFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually + [lwWarning];
recMsg.sMsgText:= recMsg.sMsgText; // as a reminder of the unbreakable association betweeb some methode names and their homonymous group
end
else if (AMethodUsed = methInfo) then begin
recMsg.setFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo];
recMsg.sMsgText:= recMsg.sMsgText; // as a reminder of the unbreakable association betweeb some methode names and their homonymous group
end
else
recMsg.setFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
end;
begin
CreateMsg;
(*IsMultiThread == true, when unit cthreads is used by a project*)
if IsMultiThread then
//Yes: it's a global variable created in this unit, and used in this unit only ;-)
goGuardian.Enter;
if FoDefaultChannels <> nil then
DispatchLogMessage(FoDefaultChannels, recMsg);
DispatchLogMessage(Channels, recMsg);
if IsMultiThread then
goGuardian.Leave;
end;
procedure TIntegratedLogger.SendBuffer(AMethodUsed: Integer; const AText: String; var pBuffer; Count: LongWord);
var
oStream: TStream;
begin
try
if Count > 0 then begin
oStream:= TMemoryStream.Create;
oStream.Write(pBuffer,Count);
end
else
oStream:= nil;
SendStream(AMethodUsed,AText,oStream); //nb: SendStream will free oStream
finally
oStream.Free;
end;
end;
procedure TIntegratedLogger.SetMaxStackCount(const AValue: Integer);
begin
if AValue < 256 then
FiMaxStackCount := AValue
else
FiMaxStackCount := 256;
end;
procedure TIntegratedLogger.SetThreadSafe;
begin
if IsMultiThread and not Assigned(goGuardian) then
goGuardian:= TGuardian.Create
else if (not IsMultiThread) and Assigned(goGuardian) then
FreeAndNil(goGuardian);
end;
constructor TIntegratedLogger.Create;
begin
SetThreadSafe;
FoChannels := TChannelList.Create;
FiMaxStackCount := 20;
FoLogStack := TStringList.Create;
FoCheckList := TStringList.Create;
with FoCheckList do begin
CaseSensitive := False;
Sorted := True; //Faster IndexOf?
end;
FoCounterList := TStringList.Create;
with FoCounterList do begin
CaseSensitive := False;
Sorted := True; //Faster IndexOf?
end;
FsetFilterDynamic_forWhatReasonsToLogActually:= lwNone; //categor{y|ies} of What is logged; by default, the logging and log nothing;
end;
destructor TIntegratedLogger.Destroy;
begin
FoChannels.Destroy;
FoLogStack.Destroy;
FoCheckList.Destroy;
FoCounterList.Destroy;
if Assigned(goGuardian) then
FreeAndNil(goGuardian);
end;
function TIntegratedLogger.CalledBy(const AMethodName: String): Boolean;
begin
Result:= FoLogStack.IndexOf(UpperCase(AMethodName)) <> -1;
end;
procedure ClearChannels(o_Channels: TChannelList);
var
i: Integer;
o_Channel: TLogChannel;
begin
for i := 0 to o_Channels.Count - 1 do begin
o_Channel := o_Channels[i];
if o_Channel.Active then
o_Channel.Clear;
end;
end;
procedure TIntegratedLogger.Clear;
begin
if FoDefaultChannels <> nil then
ClearChannels(FoDefaultChannels);
ClearChannels(Channels);
end;
function TIntegratedLogger.RectToStr(const ARect: TRect): String;
begin
with ARect do
Result:= Format('(Left: %d; Top: %d; Right: %d; Bottom: %d)',[Left,Top,Right,Bottom]);
end;
function TIntegratedLogger.PointToStr(const APoint: TPoint): String;
begin
with APoint do
Result:= Format('(X: %d; Y: %d)',[X,Y]);
end;
procedure TIntegratedLogger.Send(const AText: String);
begin
Send(FsetFilterDynamic_forWhatReasonsToLogActually,AText);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methSend,AText,nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; Args: array of const);
begin
Send(FsetFilterDynamic_forWhatReasonsToLogActually,AText,Args);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; Args: array of const);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methSend, Format(AText,Args),nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText, AValue: String);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually,AText,AValue);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText, AValue: String);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methValue,AText+' = '+AValue,nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; AValue: Integer);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually,AText,AValue);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Integer);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methValue,AText+' = '+IntToStr(AValue),nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; AValue: Cardinal);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually,AText,AValue);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Cardinal);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methValue,AText+' = '+IntToStr(AValue),nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; AValue: Double);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually,AText,AValue);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Double);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methValue,AText+' = '+FloatToStr(AValue),nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; AValue: Int64);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually,AText,AValue);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Int64);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methValue,AText+' = '+IntToStr(AValue),nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; AValue: QWord);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually,AText,AValue);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: QWord);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methValue,AText+' = '+IntToStr(AValue),nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; AValue: Boolean);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually, AText, AValue);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AValue: Boolean);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methValue, AText + ' = ' + BoolToStr(AValue, True), nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; const ARect: TRect);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually,AText,ARect);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; const ARect: TRect);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methValue,AText+ ' = '+RectToStr(ARect),nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; const APoint: TPoint);
begin
Send(FsetFilterDynamic_forWhatReasonsToLogActually,AText,APoint);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; const APoint: TPoint);
var
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
SendStream(methValue,AText+' = '+PointToStr(APoint),nil);
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; AStrList: TStrings);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually,AText,AStrList);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; o_AStrList: TStrings);
var
sStr: string;
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
if Assigned(o_AStrList) then
if o_AStrList.Count>0 then
sStr:= o_AStrList.Text
else
sStr:= ' ' { fake o_AStrList.Text }
else
sStr:= ' '; { fake o_AStrList.Text }
SendBuffer(methTStrings, AText, sStr[1], Length(sStr));
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
procedure TIntegratedLogger.Send(const AText: String; AObject: TObject);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually,AText,AObject);
end;
procedure TIntegratedLogger.Send(aSetOfFilterDynamicOverloadOneShot: TGroupOfForWhatReasonsToLogActually; const AText: String; AObject: TObject);
var
sTempStr: String;
oStream: TStream;
setOldFilterDynamic: TGroupOfForWhatReasonsToLogActually;
begin
setOldFilterDynamic:= FsetFilterDynamic_forWhatReasonsToLogActually;
FsetFilterDynamic_forWhatReasonsToLogActually:= FsetFilterDynamic_forWhatReasonsToLogActually + aSetOfFilterDynamicOverloadOneShot;
if FsetFilterDynamic_forWhatReasonsToLogActually = [] then Exit; //pre-conditions
try
oStream := nil;
sTempStr := AText + ' [';
if AObject <> nil then
begin
if AObject is TComponent then begin
oStream := TMemoryStream.Create;
oStream.WriteComponent(TComponent(AObject));
end
else
sTempStr := sTempStr + GetObjectDescription(AObject) + ' / ';
end;
sTempStr := sTempStr + ('$' + HexStr(AObject) + ']');
SendStream(methObject, sTempStr, oStream);
finally
oStream.Free;
FsetFilterDynamic_forWhatReasonsToLogActually:= setOldFilterDynamic;
end;
end;
procedure TIntegratedLogger.SendInfo(const AText: String);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText);
end;
procedure TIntegratedLogger.SendInfo(const AText: String; Args: array of const);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, Args);
end;
procedure TIntegratedLogger.SendInfo(const AText, AValue: String);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, AValue);
end;
procedure TIntegratedLogger.SendInfo(const AText: String; AValue: Integer);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, AValue);
end;
{$ifdef fpc}
procedure TIntegratedLogger.SendInfo(const AText: String; AValue: Cardinal);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, AValue);
end;
{$endif}
procedure TIntegratedLogger.SendInfo(const AText: String; AValue: Double);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, AValue);
end;
procedure TIntegratedLogger.SendInfo(const AText: String; AValue: Int64);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, AValue);
end;
procedure TIntegratedLogger.SendInfo(const AText: String; AValue: QWord);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, AValue);
end;
procedure TIntegratedLogger.SendInfo(const AText: String; AValue: Boolean);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, AValue);
end;
procedure TIntegratedLogger.SendInfo(const AText: String; const ARect: TRect);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, ARect);
end;
procedure TIntegratedLogger.SendInfo(const AText: String; const APoint: TPoint);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, APoint);
end;
procedure TIntegratedLogger.SendInfo(const AText: String; AStrList: TStrings);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, AStrList);
end;
procedure TIntegratedLogger.SendInfo(const AText: String; AObject: TObject);
begin
SendInfo(FsetFilterDynamic_forWhatReasonsToLogActually + [lwInfo], AText, AObject);
end;
procedure TIntegratedLogger.SendPointer(const AText: String; APointer: Pointer);
begin
SendPointer(FsetFilterDynamic_forWhatReasonsToLogActually,AText,APointer);
end;
procedure TIntegratedLogger.SendCallStack(const AText: String);
begin
SendCallStack(FsetFilterDynamic_forWhatReasonsToLogActually,AText);
end;
procedure TIntegratedLogger.SendException(const AText: String; AException: Exception);
begin
SendException(FsetFilterDynamic_forWhatReasonsToLogActually + [lwError], AText, AException);
end;
procedure TIntegratedLogger.SendHeapInfo(const AText: String);
begin
SendHeapInfo(FsetFilterDynamic_forWhatReasonsToLogActually,AText);
end;
procedure TIntegratedLogger.SendMemory(const AText: String; Address: Pointer; Size: LongWord; Offset: Integer);
begin
SendMemory(FsetFilterDynamic_forWhatReasonsToLogActually,AText,Address,Size,Offset)
end;