From c168722184f9b1f956510f09dac75288c1064682 Mon Sep 17 00:00:00 2001 From: Stas'M Date: Sat, 19 May 2018 01:56:06 +0300 Subject: [PATCH] Log: Don't double chat messages in console --- src/engine/e_log.pas | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/engine/e_log.pas b/src/engine/e_log.pas index 22db652..186e1bd 100644 --- a/src/engine/e_log.pas +++ b/src/engine/e_log.pas @@ -40,7 +40,7 @@ function DecodeIPV4 (ip: LongWord): string; // start Write/WriteLn driver. it will write everything to cbuf. procedure e_InitWritelnDriver (); -procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true); +procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true); procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true); @@ -68,15 +68,24 @@ begin end; +function consoleAllow (const s: String): Boolean; +begin + Result := False; + if Pos('[Chat] ', s) = 1 then + Exit; + Result := True; +end; + + procedure e_WriteLog (TextLine: String; RecordCategory: TMsgType; WriteTime: Boolean=True); begin - e_LogWritefln('%s', [TextLine], RecordCategory, WriteTime); + e_LogWritefln('%s', [TextLine], RecordCategory, WriteTime, consoleAllow(TextLine)); end; procedure e_LogWriteln (const s: AnsiString; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true); begin - e_LogWritefln('%s', [s], category, writeTime); + e_LogWritefln('%s', [s], category, writeTime, consoleAllow(s)); end; @@ -180,7 +189,7 @@ begin end; -procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true); +procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: TMsgType=TMsgType.Notify; writeTime: Boolean=true; writeConsole: Boolean=true); procedure xwrite (const s: AnsiString); begin @@ -189,7 +198,7 @@ procedure e_LogWritefln (const fmt: AnsiString; args: array of const; category: end; begin - if driverInited and (length(fmt) > 0) then + if driverInited and (length(fmt) > 0) and writeConsole then begin case category of TMsgType.Fatal: write('FATAL: '); -- 2.29.2