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, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 {$R-}
17 { $DEFINE CBLOG}
20 interface
22 uses
23 SysUtils;
25 type
39 // start Write/WriteLn driver. it will write everything to cbuf.
42 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true);
43 procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
49 var
53 implementation
55 uses
56 {$IFDEF ANDROID}
57 SDL2,
58 {$ENDIF}
61 var
68 begin
69 Result := Format('%d.%d.%d.%d', [ip and $FF, (ip shr 8) and $FF, (ip shr 16) and $FF, (ip shr 24)]);
74 begin
77 Exit;
83 begin
88 procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
89 begin
94 // returns formatted string if `writerCB` is `nil`, empty string otherwise
95 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
96 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
99 var
103 {$IFDEF ANDROID}
105 {$ENDIF}
106 begin
110 {$IFDEF ANDROID}
117 {$ENDIF}
120 begin
131 var
141 begin
144 begin
152 var
156 begin
160 begin
166 begin
170 // print string
172 begin
179 continue;
181 // process newline
183 begin
194 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true);
197 begin
202 begin
204 begin
210 writeln;
216 begin
218 try
222 exit;
227 begin
233 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
245 begin
250 //if fopened then CloseFile(xlogFile);
255 begin
260 begin
261 try
270 {$I-}
272 var
274 begin
277 begin
283 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
289 begin
295 // ////////////////////////////////////////////////////////////////////////// //
296 (* Write/WriteLn driver *)
297 //
298 // control codes:
299 // CR, LF, BS
300 // TAB: tab space = 4
301 //
302 // userData[1]: current x (for tabs)
303 // userData[2]: #13 was eaten, we should skip next #10
304 //
305 type
308 const
314 var
319 begin
323 begin
324 // look for some special char
328 begin
333 {$IFDEF CBLOG}
335 {$ENDIF}
338 begin
344 continue;
346 // process special chars
350 // tab
352 begin
353 {$IFDEF CBLOG}
355 {$ENDIF}
356 repeat
360 continue;
362 // cr, lf
364 begin
365 {$IFDEF CBLOG}
367 {$ENDIF}
369 begin
374 continue;
383 begin
392 var
395 begin
405 begin
410 begin
416 begin
418 begin
421 begin
424 begin
439 begin
440 //e_InitWritelnDriver();