1 (* Copyright (C) DooM 2D:Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 {$R-}
18 { $DEFINE CBLOG}
21 interface
23 uses
24 SysUtils;
26 type
36 procedure e_WriteLog (TextLine: String; RecordCategory: TRecordCategory; WriteTime: Boolean=True);
40 // start Write/WriteLn driver. it will write everything to cbuf.
43 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TRecordCategory=MSG_NOTIFY; writeTime: Boolean=true);
44 procedure e_LogWriteln (const s: AnsiString; category: TRecordCategory=MSG_NOTIFY; writeTime: Boolean=true);
50 var
54 implementation
56 uses
59 var
66 begin
67 Result := Format('%d.%d.%d.%d', [ip and $FF, (ip shr 8) and $FF, (ip shr 16) and $FF, (ip shr 24)]);
71 procedure e_WriteLog (TextLine: String; RecordCategory: TRecordCategory; WriteTime: Boolean=True);
72 begin
77 procedure e_LogWriteln (const s: AnsiString; category: TRecordCategory=MSG_NOTIFY; writeTime: Boolean=true);
78 begin
83 // returns formatted string if `writerCB` is `nil`, empty string otherwise
84 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
85 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
88 var
92 begin
96 begin
107 var
117 begin
120 begin
128 var
132 begin
136 begin
142 begin
146 // print string
148 begin
155 continue;
157 // process newline
159 begin
170 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TRecordCategory=MSG_NOTIFY; writeTime: Boolean=true);
173 begin
178 begin
180 begin
186 writeln;
192 begin
194 try
198 exit;
203 begin
209 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
221 begin
226 //if fopened then CloseFile(xlogFile);
231 begin
236 begin
237 try
246 {$I-}
248 var
250 begin
253 begin
259 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
265 begin
271 // ////////////////////////////////////////////////////////////////////////// //
272 (* Write/WriteLn driver *)
273 //
274 // control codes:
275 // CR, LF, BS
276 // TAB: tab space = 4
277 //
278 // userData[1]: current x (for tabs)
279 // userData[2]: #13 was eaten, we should skip next #10
280 //
281 type
284 const
290 var
295 begin
299 begin
300 // look for some special char
304 begin
309 {$IFDEF CBLOG}
311 {$ENDIF}
314 begin
320 continue;
322 // process special chars
326 // tab
328 begin
329 {$IFDEF CBLOG}
331 {$ENDIF}
332 repeat
336 continue;
338 // cr, lf
340 begin
341 {$IFDEF CBLOG}
343 {$ENDIF}
345 begin
350 continue;
359 begin
368 var
371 begin
381 begin
386 begin
392 begin
394 begin
397 begin
400 begin
415 begin
416 //e_InitWritelnDriver();