Comprehensive Logging with mORMot 2 on Delphi and FPC
ArnaudBouchez1
27 views
76 slides
Oct 29, 2025
Slide 1 of 76
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
About This Presentation
The logging feature of mORMot is worth investigating for any Delphi or FPC project, even if you do not need any other part of the library. This session will present what makes mORMot unique in the modern object Pascal scene.
Hands-On
How to use only some part of the mORMot 2 toolbox
Genera...
The logging feature of mORMot is worth investigating for any Delphi or FPC project, even if you do not need any other part of the library. This session will present what makes mORMot unique in the modern object Pascal scene.
Hands-On
How to use only some part of the mORMot 2 toolbox
General best-practices about logging
Server-side logging particularities
A cross-compiler and cross-platform journey
Size: 515.22 KB
Language: en
Added: Oct 29, 2025
Slides: 76 pages
Slide Content
Comprehensive Logging
with mORMot 2
The more logs…
the better
TSynLog.Family
TSynLogFamily.Level
a setof levels
to rule them all
TSynLog.Add
TSynLoginstance
•Map a log file on disk
•Host of the Log() methods
TSynLog.Log()
TSynLog.Log() overloads
•Thread-safe and very efficient
•UTF-8/JSON serialization
•Formatting with % place holder
TSynLog.Log()
TSynLog.Log() overloads
•Thread-safe and very efficient
•UTF-8/JSON serialization
•Formatting with % place holder
(not %s %d with runtime errors)
TSynLog.Log()
procedure TSomeClass.SomeMethod(a: integer);
begin
TSynLog.Add.Log(sllTrace,'SomeMethoda=%',[a],self);
// do some stuff
if error <> '' then
TSynLog.Add.Log(sllError, 'SomeMethodfailed as %',
[error], self);
end;
TSynLog.Log()
procedure TSomeClass.SomeMethod(a: variant);
begin
try
// do some stuff
except
on E: Exception do
TSynLog.Add.Log(sllError, 'SomeMethod(%) raised %',
[a, E], self);
end;
ISynLog
procedure TSomeClass.DoIt(param: TSomeObject)
varlog: ISynLog; // local variable
begin
log := TSynLog.Enter(self, 'DoIt');
// do some stuff
if Assigned(log) then// may be nil if no sllEnter
log.Log(sllInfo, 'DoItcalled as %', [param], self);
end; // when log is out-of-scope, log the method leaving
ISynLog
procedure TSomeClass.DoIt(param: TSomeObject)
varlog: ISynLog;
begin
TSynLog.EnterLocal(log, self, 'DoIt'); // slightly faster
// do some stuff
if Assigned(log) then// may be nil if no sllEnter
log.Log(sllInfo, 'DoItcalled as %', [param], self);
end; // when log is out-of-scope, log the method leaving
ISynLog
procedure TSomeClass.DoIt(param: TSomeObject)
begin
TSynLog.Enter(self, 'DoIt');// returns an ISynLog
// do some stuff
end; // when ISynLogis out-of-scope, log the method leaving
ISynLog
procedure TSomeClass.DoIt(param: TSomeObject)
begin
TSynLog.Enter(self, 'DoIt');
// do some stuff
end; // when ISynLogis out-of-scope, log the method leaving
ISynLog
procedure TSomeClass.DoIt(param: TSomeObject)
begin
TSynLog.Enter(self, 'DoIt');
// do some stuff
end; // ISYNLOG RELEASED NOW
WARNING: SCOPE IS AT METHOD ENDINGWITH OLDDELPHI
ISynLog
procedure TSomeClass.DoIt(param: TSomeObject)
begin
TSynLog.Enter(self, 'DoIt');
// ISYNLOG RELEASED NOW
// do some stuff
end;
WARNING: SCOPE IS ASAP/LOCALWITH FPCOR LATESTDELPHI
ISynLog
procedure TSomeClass.DoIt(param: TSomeObject)
varlog: ISynLog; // use local varon modern Delphi or FPC
begin
TSynLog.EnterLocal(log, self, 'DoIt');
// do some stuff
if Assigned(log) then// may be nil if no sllEnter
log.Log(sllInfo, 'DoItcalled as %', [param], self);
end; // when log is out-of-scope, log the method leaving
TSynLogClass or Instance
SHOW ME THE CODE !
Today’s Special
•TSynLogclass or instance
•The LogViewertool
•Advanced features
•Logging with love
LogViewer
LogViewer
•VCL/LCL Open Source Tool
LogViewer
•VCL/LCL Open Source Tool
•Map the file in memory
LogViewer
•VCL/LCL Open Source Tool
•Map the file in memory
•Index/search/filter/view
LogViewer
•VCL/LCL Open Source Tool
•Map the file in memory
•Index/search/filter/view
•Thread oriented
LogViewer
SHOW ME THE CODE !
SHOW ME THE TOOL !
Today’s Special
•TSynLogclass or instance
•The LogViewertool
•Advanced features
•Logging with love
Advanced Features
Advanced Features
•Integrated in whole Framework
•Optimized Generation
•TSynLogFamilyproperties
•Cross-OS and Cross-Compiler
Advanced Features
•Integrated in whole Framework
•Network/socket/http process
•REST/SOA calls
•Database queries (SQL/NoSQL)
Advanced Features
•Integrated in whole Framework
•Network/socket/http process
•REST/SOA calls
•Database queries (SQL/NoSQL)
BUILT-IN !
Advanced Features
Optimized Generation
•Full rewrite in latest mORMot 2
•No transient memory allocation
•Validated on production servers