-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathfbclone.logger.pas
More file actions
95 lines (76 loc) · 2.75 KB
/
fbclone.logger.pas
File metadata and controls
95 lines (76 loc) · 2.75 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
unit fbclone.logger;
interface
uses
SysUtils;
type
ConsoleString = type AnsiString(850);
TLogLevel = (llError, llInfo);
ILogger = interface
procedure Trace(const Msg: string; Level: TLogLevel); overload;
procedure Trace(const Msg: string; const Params: array of const; Level: TLogLevel); overload;
procedure Info(const Msg: string = ''); overload;
procedure Info(const Msg: string; const Params: array of const); overload;
procedure Error(const Msg: string = ''); overload;
procedure Error(const Msg: string; const Params: array of const); overload;
procedure Progress(const Msg: string); overload;
procedure Progress(const Msg: string; const Params: array of const); overload;
end;
TAbstractLogger = class(TInterfacedObject, ILogger)
public
procedure Trace(const Msg: string; Level: TLogLevel); overload; virtual; abstract;
procedure Trace(const Msg: string; const Params: array of const; Level: TLogLevel); overload; virtual;
procedure Info(const Msg: string = ''); overload; virtual;
procedure Info(const Msg: string; const Params: array of const); overload; virtual;
procedure Error(const Msg: string = ''); overload; virtual;
procedure Error(const Msg: string; const Params: array of const); overload; virtual;
procedure Progress(const Msg: string); overload; virtual; abstract;
procedure Progress(const Msg: string; const Params: array of const); overload;
end;
TConsoleLogger = class(TAbstractLogger)
public
procedure Trace(const Msg: string; Level: TLogLevel); override;
procedure Progress(const Msg: string); override;
end;
implementation
{ TAbstractLogger }
procedure TAbstractLogger.Trace(const Msg: string; const Params: array of const;
Level: TLogLevel);
begin
Trace(Format(Msg, Params),Level);
end;
procedure TAbstractLogger.Info(const Msg: string);
begin
Trace(Msg, llInfo);
end;
procedure TAbstractLogger.Info(const Msg: string;
const Params: array of const);
begin
Trace(Msg, Params, llInfo);
end;
procedure TAbstractLogger.Progress(const Msg: string;
const Params: array of const);
begin
Progress(Format(Msg, Params));
end;
procedure TAbstractLogger.Error(const Msg: string;
const Params: array of const);
begin
Trace(Msg, Params, llError);
end;
procedure TAbstractLogger.Error(const Msg: string);
begin
Trace(Msg, llError);
end;
{ TConsoleLogger }
procedure TConsoleLogger.Progress(const Msg: string);
begin
Write(Msg, StringOfChar(' ', 80 - (Length(Msg) + 1)), #13);
end;
procedure TConsoleLogger.Trace(const Msg: string; Level: TLogLevel);
begin
if Level = llError then
WriteLn(ErrOutput, ConsoleString(Msg))
else
WriteLn(ConsoleString(Msg));
end;
end.