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