b795d57e2175e596762d100e44843f3ac6433483
[rocksndiamonds.git] / src / game_sp / ErrorReporting.c
1 // ----------------------------------------------------------------------------
2 // ErrorReporting.c
3 // ----------------------------------------------------------------------------
4
5 #include "ErrorReporting.h"
6
7 static char * GetErrLogPath();
8 static char * GetTraceLogPath();
9
10 // static char *VB_Name = "modErrorReporting";
11
12 // --- Option Explicit
13
14 static char *GetErrLogPath()
15 {
16   static char *GetErrLogPath;
17
18   // GetErrLogPath = GET_PATH(WithSlash(App.Path), "Error.log");
19   GetErrLogPath = "Error.log";
20
21   return GetErrLogPath;
22 }
23
24 static char *GetTraceLogPath()
25 {
26   static char *GetTraceLogPath;
27
28   // GetTraceLogPath = GET_PATH(WithSlash(App.Path), "Trace.log");
29   GetTraceLogPath = "Trace.log";
30
31   return GetTraceLogPath;
32 }
33
34 void Trace(char *Source, char *Message)
35 {
36   // Dim Path$, FNum%, bIsOpen As Boolean
37   //  Path = GetTraceLogPath()
38   //  FNum = FreeFile
39   //  bIsOpen = False
40   //  On Error GoTo TraceEH
41   //  Open Path For Append Access Write As FNum
42   //    bIsOpen = True
43   //    ' --- Print #FNum, Now & "  " & Source & " :  " & Message
44   //  On Error GoTo 0
45   // TraceEH:
46   //  If bIsOpen Then Close FNum
47 }
48
49 void ReportError(char *Source, char *Message)
50 {
51   char *Path;
52   FILE *FNum;
53   boolean bIsOpen;
54
55   Path = GetErrLogPath();
56   // FNum = FreeFile();
57   bIsOpen = False;
58
59   // --- On Error GoTo ReportErrorEH
60   FNum = fopen(Path, "ab");
61   bIsOpen = True;
62   // --- Print #FNum, Now & "    SOURCE = " & Source & "    ErrMessage = " & Message
63   // --- On Error GoTo 0
64
65
66   // ReportErrorEH:
67   if (bIsOpen)
68     fclose(FNum);
69 }
70
71 void InitErrorReporting()
72 {
73   char *Path;
74
75   Path = GetErrLogPath();
76   MayKill(Path);
77   Path = GetTraceLogPath();
78   MayKill(Path);
79 }