-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathLightCore.LogTypes.pas
More file actions
61 lines (46 loc) · 2.45 KB
/
LightCore.LogTypes.pas
File metadata and controls
61 lines (46 loc) · 2.45 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
UNIT LightCore.LogTypes;
{=============================================================================================================
www.GabrielMoraru.com
2026.01
Github.com/GabrielOnDelphi/Delphi-LightSaber/blob/main/System/Copyright.txt
A simple but effective visual log control/library.
The programmer can send messages to the log that will be shown or not, depending on the chosen verbosity level of the log (see Verbosity property).
**Visual/Non-visual**
There is a non-visual log (TRamLog) and a visual log (TRichLog). The idea is that your non-visual objects can send data to the non-visual log, for example in a batch job. At the end of the batch all collected messages can be shown in the visual log.
Alternatively, if you connect the TRamLog to the visual log, the messages are shown in real time, as the batch job progresses.
There is a pre-defined form that holds the log. To show it, call CreateLogForm in FormLog.pas
The purpose is to have one single log window per application that will receive messages from the entire application.
**Verbosity:**
Supports several verbosity levels (verbose, info, warnings, errors, etc).
Receives only messages that are above the specified verbosity threshold.
For example, if the log is set to show only warnings and errors and you send a messages marked as "verbose", then the messages will not be shown.
Each verbosity level has a predefined color.
**I/O**
The log can be saved to disk as a binary file so it can be restored on the next app startup.
Tester:
Demo\LightLog\
=============================================================================================================}
INTERFACE
USES
System.SysUtils;
TYPE
TLogVerbLvl= (lvDebug, lvVerbose, lvHints {Default}, lvInfos, lvImportant, lvWarnings, lvErrors); { Exist also 7 which is of type 'Msg' and it is always shown in log }
CONST
DefaultVerbosity= lvInfos;
function Verbosity2String(Verbosity: TLogVerbLvl): string;
IMPLEMENTATION
function Verbosity2String(Verbosity: TLogVerbLvl): string;
begin
case Verbosity of
lvDebug : Result := 'Debug';
lvVerbose : Result := 'Verbose';
lvHints : Result := 'Hints';
lvInfos : Result := 'Info'; { This is the default level of verbosity }
lvImportant : Result := 'Important';
lvWarnings : Result := 'Warnings';
lvErrors : Result := 'Errors';
else
RAISE Exception.Create('Invalid verbosity');
end;
end;
end.