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);
47 implementation
49 uses
50 {$IFDEF ANDROID}
51 SDL2,
52 {$ENDIF}
55 var
62 begin
63 Result := Format('%d.%d.%d.%d', [ip and $FF, (ip shr 8) and $FF, (ip shr 16) and $FF, (ip shr 24)]);
68 begin
71 Exit;
77 begin
82 procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
83 begin
88 // returns formatted string if `writerCB` is `nil`, empty string otherwise
89 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
90 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
93 var
97 {$IFDEF ANDROID}
99 {$ENDIF}
100 begin
104 {$IFDEF ANDROID}
111 {$ENDIF}
114 begin
125 var
135 begin
138 begin
146 var
150 begin
154 begin
160 begin
164 // print string
166 begin
173 continue;
175 // process newline
177 begin
188 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true);
191 begin
196 begin
198 begin
204 writeln;
210 begin
212 try
216 exit;
221 begin
227 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
239 begin
244 //if fopened then CloseFile(xlogFile);
249 begin
254 begin
255 try
264 {$I-}
266 var
268 begin
271 begin
277 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
283 begin
289 // ////////////////////////////////////////////////////////////////////////// //
290 (* Write/WriteLn driver *)
291 //
292 // control codes:
293 // CR, LF, BS
294 // TAB: tab space = 4
295 //
296 // userData[1]: current x (for tabs)
297 // userData[2]: #13 was eaten, we should skip next #10
298 //
299 type
302 const
308 var
313 begin
317 begin
318 // look for some special char
322 begin
327 {$IFDEF CBLOG}
329 {$ENDIF}
332 begin
338 continue;
340 // process special chars
344 // tab
346 begin
347 {$IFDEF CBLOG}
349 {$ENDIF}
350 repeat
354 continue;
356 // cr, lf
358 begin
359 {$IFDEF CBLOG}
361 {$ENDIF}
363 begin
368 continue;
377 begin
386 var
389 begin
399 begin
404 begin
410 begin
412 begin
415 begin
418 begin
433 begin
434 //e_InitWritelnDriver();