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
24 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);
48 implementation
50 uses
51 {$IFDEF ANDROID}
52 SDL2,
53 {$ENDIF}
56 var
63 begin
67 begin
68 e_DeinitLog
73 begin
74 Result := Format('%d.%d.%d.%d', [ip and $FF, (ip shr 8) and $FF, (ip shr 16) and $FF, (ip shr 24)]);
79 begin
82 Exit;
88 begin
93 procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
94 begin
99 // returns formatted string if `writerCB` is `nil`, empty string otherwise
100 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
101 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
104 var
108 {$IFDEF ANDROID}
110 {$ENDIF}
111 begin
115 {$IFDEF ANDROID}
122 {$ENDIF}
125 begin
136 var
146 begin
149 begin
157 var
161 begin
165 begin
171 begin
175 // print string
177 begin
184 continue;
186 // process newline
188 begin
199 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true);
202 begin
207 begin
209 begin
215 writeln;
221 begin
223 try
227 exit;
232 begin
238 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
250 begin
255 //if fopened then CloseFile(xlogFile);
260 begin
265 begin
266 try
275 {$I-}
277 var
279 begin
282 begin
288 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
294 begin
300 // ////////////////////////////////////////////////////////////////////////// //
301 (* Write/WriteLn driver *)
302 //
303 // control codes:
304 // CR, LF, BS
305 // TAB: tab space = 4
306 //
307 // userData[1]: current x (for tabs)
308 // userData[2]: #13 was eaten, we should skip next #10
309 //
310 type
313 const
319 var
324 begin
328 begin
329 // look for some special char
333 begin
338 {$IFDEF CBLOG}
340 {$ENDIF}
343 begin
349 continue;
351 // process special chars
355 // tab
357 begin
358 {$IFDEF CBLOG}
360 {$ENDIF}
361 repeat
365 continue;
367 // cr, lf
369 begin
370 {$IFDEF CBLOG}
372 {$ENDIF}
374 begin
379 continue;
388 begin
397 var
400 begin
410 begin
415 begin
421 begin
423 begin
426 begin
429 begin
444 begin
445 //e_InitWritelnDriver();