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);
44 procedure e_LogWriteln (const s: AnsiString; category: TRecordCategory=MSG_NOTIFY; writeTime: Boolean=true);
47 var
51 implementation
53 uses
56 var
63 begin
64 Result := Format('%d.%d.%d.%d', [ip and $FF, (ip shr 8) and $FF, (ip shr 16) and $FF, (ip shr 24)]);
68 procedure e_WriteLog (TextLine: String; RecordCategory: TRecordCategory; WriteTime: Boolean=True);
69 begin
74 procedure e_LogWriteln (const s: AnsiString; category: TRecordCategory=MSG_NOTIFY; writeTime: Boolean=true);
75 begin
80 // returns formatted string if `writerCB` is `nil`, empty string otherwise
81 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
82 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
85 var
89 begin
93 begin
104 var
114 begin
117 begin
125 var
129 begin
133 begin
139 begin
143 // print string
145 begin
152 continue;
154 // process newline
156 begin
167 procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TRecordCategory=MSG_NOTIFY; writeTime: Boolean=true);
170 begin
175 begin
177 begin
183 writeln;
189 begin
191 try
195 exit;
200 begin
206 if writeTime then begin xlogPrefix += '['; xlogPrefix += TimeToStr(Time); xlogPrefix += '] '; end;
218 begin
223 //if fopened then CloseFile(xlogFile);
228 begin
233 begin
234 try
244 begin
250 // ////////////////////////////////////////////////////////////////////////// //
251 (* Write/WriteLn driver *)
252 //
253 // control codes:
254 // CR, LF, BS
255 // TAB: tab space = 4
256 //
257 // userData[1]: current x (for tabs)
258 // userData[2]: #13 was eaten, we should skip next #10
259 //
260 type
263 const
269 var
274 begin
278 begin
279 // look for some special char
283 begin
288 {$IFDEF CBLOG}
290 {$ENDIF}
293 begin
299 continue;
301 // process special chars
305 // tab
307 begin
308 {$IFDEF CBLOG}
310 {$ENDIF}
311 repeat
315 continue;
317 // cr, lf
319 begin
320 {$IFDEF CBLOG}
322 {$ENDIF}
324 begin
329 continue;
338 begin
347 var
350 begin
360 begin
365 begin
371 begin
373 begin
376 begin
379 begin
394 begin
395 //e_InitWritelnDriver();