forked from rchastain/nero5
-
Notifications
You must be signed in to change notification settings - Fork 2
/
log.pas
executable file
·68 lines (55 loc) · 1.13 KB
/
log.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
unit log;
interface
uses
sysutils;
procedure append(const atext: string; const asecondfile: boolean = false); overload;
implementation
const
cdir = 'log';
var
lfile: array[boolean] of text;
llogcreated: boolean;
procedure openlog;
var
lfilename: string;
lidx: boolean;
begin
lfilename := cdir + directoryseparator +
formatdatetime('yyyymmddhhnnsszzz"-%d.log"', now);
if directoryexists(cdir)
or createdir(cdir) then
begin
for lidx := false to true do
begin
assign(lfile[lidx], format(lfilename, [ord(lidx)]));
rewrite(lfile[lidx]);
end;
llogcreated := true;
end else
llogcreated := false;
end;
procedure closelog;
begin
if llogcreated then
begin
close(lfile[false]);
close(lfile[true]);
end;
end;
procedure append(const atext: string; const asecondfile: boolean);
begin
{$ifdef createlog}
if llogcreated then
begin
writeln(lfile[asecondfile], atext);
flush(lfile[asecondfile]);
end;
{$endif}
end;
{$ifdef createlog}
initialization
openlog;
finalization
closelog;
{$endif}
end.