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
40 // start Write/WriteLn driver. it will write everything to cbuf.
43 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true);
44 procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.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)]);
72 begin
75 Exit;
81 begin
86 procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
87 begin
92 // returns formatted string if `writerCB` is `nil`, empty string otherwise
93 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
94 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
97 var
101 {$IFDEF ANDROID}
103 {$ENDIF}
104 begin
108 {$IFDEF ANDROID}
115 {$ENDIF}
118 begin
129 var
139 begin
142 begin
150 var
154 begin
158 begin
164 begin
168 // print string
170 begin
177 continue;
179 // process newline
181 begin
192 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true);
195 begin
200 begin
202 begin
208 writeln;
214 begin
216 try
220 exit;
225 begin
231 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
243 begin
248 //if fopened then CloseFile(xlogFile);
253 begin
258 begin
259 try
268 {$I-}
270 var
272 begin
275 begin
281 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
287 begin
293 // ////////////////////////////////////////////////////////////////////////// //
294 (* Write/WriteLn driver *)
295 //
296 // control codes:
297 // CR, LF, BS
298 // TAB: tab space = 4
299 //
300 // userData[1]: current x (for tabs)
301 // userData[2]: #13 was eaten, we should skip next #10
302 //
303 type
306 const
312 var
317 begin
321 begin
322 // look for some special char
326 begin
331 {$IFDEF CBLOG}
333 {$ENDIF}
336 begin
342 continue;
344 // process special chars
348 // tab
350 begin
351 {$IFDEF CBLOG}
353 {$ENDIF}
354 repeat
358 continue;
360 // cr, lf
362 begin
363 {$IFDEF CBLOG}
365 {$ENDIF}
367 begin
372 continue;
381 begin
390 var
393 begin
403 begin
408 begin
414 begin
416 begin
419 begin
422 begin
437 begin
438 //e_InitWritelnDriver();