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
92 {$IFDEF ANDROID}
94 {$ENDIF}
95 begin
99 {$IFDEF ANDROID}
106 {$ENDIF}
109 begin
120 var
130 begin
133 begin
141 var
145 begin
149 begin
155 begin
159 // print string
161 begin
168 continue;
170 // process newline
172 begin
183 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true);
186 begin
191 begin
193 begin
199 writeln;
205 begin
207 try
211 exit;
216 begin
222 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
234 begin
239 //if fopened then CloseFile(xlogFile);
244 begin
249 begin
250 try
259 {$I-}
261 var
263 begin
266 begin
272 if (IOResult = 0) then begin writeln(tfo, '====================='); DumpExceptionBackTrace(tfo); CloseFile(tfo); end;
278 begin
284 // ////////////////////////////////////////////////////////////////////////// //
285 (* Write/WriteLn driver *)
286 //
287 // control codes:
288 // CR, LF, BS
289 // TAB: tab space = 4
290 //
291 // userData[1]: current x (for tabs)
292 // userData[2]: #13 was eaten, we should skip next #10
293 //
294 type
297 const
303 var
308 begin
312 begin
313 // look for some special char
317 begin
322 {$IFDEF CBLOG}
324 {$ENDIF}
327 begin
333 continue;
335 // process special chars
339 // tab
341 begin
342 {$IFDEF CBLOG}
344 {$ENDIF}
345 repeat
349 continue;
351 // cr, lf
353 begin
354 {$IFDEF CBLOG}
356 {$ENDIF}
358 begin
363 continue;
372 begin
381 var
384 begin
394 begin
399 begin
405 begin
407 begin
410 begin
413 begin
428 begin
429 //e_InitWritelnDriver();