8ffb75d0d852147ac6cc227e63ceded7cc7123a0
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);
44 procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
50 var
54 implementation
56 uses
59 var
66 begin
67 Result := Format('%d.%d.%d.%d', [ip and $FF, (ip shr 8) and $FF, (ip shr 16) and $FF, (ip shr 24)]);
72 begin
77 procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
78 begin
83 // returns formatted string if `writerCB` is `nil`, empty string otherwise
84 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
85 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
88 var
93 begin
97 {$IFDEF ANDROID}
104 {$ENDIF ANDROID}
107 begin
118 var
128 begin
131 begin
139 var
143 begin
147 begin
153 begin
157 // print string
159 begin
166 continue;
168 // process newline
170 begin
181 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
184 begin
189 begin
191 begin
197 writeln;
203 begin
205 try
209 exit;
214 begin
220 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
232 begin
237 //if fopened then CloseFile(xlogFile);
242 begin
247 begin
248 try
257 {$I-}
259 var
261 begin
264 begin
270 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
276 begin
282 // ////////////////////////////////////////////////////////////////////////// //
283 (* Write/WriteLn driver *)
284 //
285 // control codes:
286 // CR, LF, BS
287 // TAB: tab space = 4
288 //
289 // userData[1]: current x (for tabs)
290 // userData[2]: #13 was eaten, we should skip next #10
291 //
292 type
295 const
301 var
306 begin
310 begin
311 // look for some special char
315 begin
320 {$IFDEF CBLOG}
322 {$ENDIF}
325 begin
331 continue;
333 // process special chars
337 // tab
339 begin
340 {$IFDEF CBLOG}
342 {$ENDIF}
343 repeat
347 continue;
349 // cr, lf
351 begin
352 {$IFDEF CBLOG}
354 {$ENDIF}
356 begin
361 continue;
370 begin
379 var
382 begin
392 begin
397 begin
403 begin
405 begin
408 begin
411 begin
426 begin
427 //e_InitWritelnDriver();