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 {$IFDEF ANDROID}
58 SDL2,
59 {$ENDIF}
62 var
69 begin
70 Result := Format('%d.%d.%d.%d', [ip and $FF, (ip shr 8) and $FF, (ip shr 16) and $FF, (ip shr 24)]);
75 begin
78 Exit;
84 begin
89 procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
90 begin
95 // returns formatted string if `writerCB` is `nil`, empty string otherwise
96 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
97 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
100 var
104 {$IFDEF ANDROID}
106 {$ENDIF}
107 begin
111 {$IFDEF ANDROID}
118 {$ENDIF}
121 begin
132 var
142 begin
145 begin
153 var
157 begin
161 begin
167 begin
171 // print string
173 begin
180 continue;
182 // process newline
184 begin
195 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true);
198 begin
203 begin
205 begin
211 writeln;
217 begin
219 try
223 exit;
228 begin
234 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
246 begin
251 //if fopened then CloseFile(xlogFile);
256 begin
261 begin
262 try
271 {$I-}
273 var
275 begin
278 begin
284 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
290 begin
296 // ////////////////////////////////////////////////////////////////////////// //
297 (* Write/WriteLn driver *)
298 //
299 // control codes:
300 // CR, LF, BS
301 // TAB: tab space = 4
302 //
303 // userData[1]: current x (for tabs)
304 // userData[2]: #13 was eaten, we should skip next #10
305 //
306 type
309 const
315 var
320 begin
324 begin
325 // look for some special char
329 begin
334 {$IFDEF CBLOG}
336 {$ENDIF}
339 begin
345 continue;
347 // process special chars
351 // tab
353 begin
354 {$IFDEF CBLOG}
356 {$ENDIF}
357 repeat
361 continue;
363 // cr, lf
365 begin
366 {$IFDEF CBLOG}
368 {$ENDIF}
370 begin
375 continue;
384 begin
393 var
396 begin
406 begin
411 begin
417 begin
419 begin
422 begin
425 begin
440 begin
441 //e_InitWritelnDriver();