-
Notifications
You must be signed in to change notification settings - Fork 6
/
vpkLogger.Mod
80 lines (67 loc) · 1.35 KB
/
vpkLogger.Mod
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
MODULE vpkLogger;
IMPORT Out, Strings, vpkTime;
CONST
deca = 10;
PROCEDURE GetDecas(number: LONGINT): LONGINT;
VAR
i: LONGINT;
BEGIN
i := 1;
WHILE number > deca DO
number := number DIV deca;
INC(i);
END;
RETURN i;
END GetDecas;
PROCEDURE LogInt*(number: LONGINT);
BEGIN
Out.Int(number, GetDecas(number));
END LogInt;
PROCEDURE LogIntLn*(number: LONGINT);
BEGIN
LogInt(number);
Out.Ln();
END LogIntLn;
PROCEDURE LogNormalized*(number, normal: LONGINT);
VAR
decimals, i: LONGINT;
BEGIN
i:=0;
decimals := GetDecas(number);
WHILE decimals + i < normal DO
INC(i);
Out.Int(0, 1)
END;
LogInt(number);
END LogNormalized;
PROCEDURE Log*(buff: ARRAY OF CHAR);
VAR
year, month, day, hour, min, sec, i: LONGINT;
BEGIN
vpkTime.Now(year, month, day, hour, min, sec);
LogNormalized(year, 4);
Out.String("/");
LogNormalized(month, 2);
Out.String("/");
LogNormalized(day, 2);
Out.String(" ");
LogNormalized(hour, 2);
Out.String("-");
LogNormalized(min, 2);
Out.String("-");
LogNormalized(sec, 2);
Out.String(" :- ");
Out.String(buff)
END Log;
PROCEDURE Ln*;
BEGIN
Out.Ln
END Ln;
PROCEDURE Char*(char: CHAR);
VAR
string :ARRAY 1 OF CHAR;
BEGIN
string[0] :=char;
Log(string);
END Char;
END vpkLogger.