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
57 {SDL2,}
60 var
67 begin
68 Result := Format('%d.%d.%d.%d', [ip and $FF, (ip shr 8) and $FF, (ip shr 16) and $FF, (ip shr 24)]);
73 begin
76 Exit;
82 begin
87 procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
88 begin
93 // returns formatted string if `writerCB` is `nil`, empty string otherwise
94 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
95 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
98 var
102 {$IFDEF ANDROID}
104 {$ENDIF}
105 begin
109 {$IFDEF ANDROID}
116 {$ENDIF}
119 begin
130 var
140 begin
143 begin
151 var
155 begin
159 begin
165 begin
169 // print string
171 begin
178 continue;
180 // process newline
182 begin
193 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true);
196 begin
201 begin
203 begin
209 writeln;
215 begin
217 try
221 exit;
226 begin
232 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
244 begin
249 //if fopened then CloseFile(xlogFile);
254 begin
259 begin
260 try
269 {$I-}
271 var
273 begin
276 begin
282 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
288 begin
294 // ////////////////////////////////////////////////////////////////////////// //
295 (* Write/WriteLn driver *)
296 //
297 // control codes:
298 // CR, LF, BS
299 // TAB: tab space = 4
300 //
301 // userData[1]: current x (for tabs)
302 // userData[2]: #13 was eaten, we should skip next #10
303 //
304 type
307 const
313 var
318 begin
322 begin
323 // look for some special char
327 begin
332 {$IFDEF CBLOG}
334 {$ENDIF}
337 begin
343 continue;
345 // process special chars
349 // tab
351 begin
352 {$IFDEF CBLOG}
354 {$ENDIF}
355 repeat
359 continue;
361 // cr, lf
363 begin
364 {$IFDEF CBLOG}
366 {$ENDIF}
368 begin
373 continue;
382 begin
391 var
394 begin
404 begin
409 begin
415 begin
417 begin
420 begin
423 begin
438 begin
439 //e_InitWritelnDriver();