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
36 procedure e_WriteLog (TextLine: String; RecordCategory: TRecordCategory; WriteTime: Boolean=True);
40 // start Write/WriteLn driver. it will write everything to cbuf.
43 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TRecordCategory=MSG_NOTIFY; writeTime: Boolean=true);
46 var
50 implementation
52 uses
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)]);
67 procedure e_WriteLog (TextLine: String; RecordCategory: TRecordCategory; WriteTime: Boolean=True);
68 begin
73 // returns formatted string if `writerCB` is `nil`, empty string otherwise
74 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
75 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
78 var
82 begin
86 begin
97 var
107 begin
110 begin
118 var
122 begin
126 begin
132 begin
136 // print string
138 begin
145 continue;
147 // process newline
149 begin
160 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TRecordCategory=MSG_NOTIFY; writeTime: Boolean=true);
163 begin
168 begin
170 begin
176 writeln;
182 begin
184 try
188 exit;
193 begin
199 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
211 begin
216 //if fopened then CloseFile(xlogFile);
221 begin
226 begin
227 try
237 begin
243 // ////////////////////////////////////////////////////////////////////////// //
244 (* Write/WriteLn driver *)
245 //
246 // control codes:
247 // CR, LF, BS
248 // TAB: tab space = 4
249 //
250 // userData[1]: current x (for tabs)
251 // userData[2]: #13 was eaten, we should skip next #10
252 //
253 type
256 const
262 var
267 begin
271 begin
272 // look for some special char
276 begin
281 {$IFDEF CBLOG}
283 {$ENDIF}
286 begin
292 continue;
294 // process special chars
298 // tab
300 begin
301 {$IFDEF CBLOG}
303 {$ENDIF}
304 repeat
308 continue;
310 // cr, lf
312 begin
313 {$IFDEF CBLOG}
315 {$ENDIF}
317 begin
322 continue;
331 begin
340 var
343 begin
353 begin
358 begin
364 begin
366 begin
369 begin
372 begin
387 begin
388 //e_InitWritelnDriver();