@@ -26,6 +26,14 @@ CScriptDebugging::CScriptDebugging ( CLuaManager* pLuaManager )
2626 m_bTriggeringOnDebugMessage = false ;
2727}
2828
29+ CScriptDebugging::~CScriptDebugging ( void )
30+ {
31+ // Flush any pending duplicate loggings
32+ m_DuplicateLineFilter.Flush ();
33+ UpdateLogOutput ();
34+
35+ ClearPlayers ();
36+ }
2937
3038bool CScriptDebugging::AddPlayer ( CPlayer& Player, unsigned int uiLevel )
3139{
@@ -389,41 +397,30 @@ void CScriptDebugging::LogString ( const char* szPrePend, const SLuaDebugInfo& l
389397 m_bTriggeringOnDebugMessage = false ;
390398 }
391399
392- // Log it to the file if enough level
393- if ( m_uiLogFileLevel >= uiMinimumDebugLevel )
394- {
395- PrintLog ( strText );
396- }
397-
398- // Log to console
399- CLogger::LogPrintf ( " %s\n " , strText.c_str () );
400+ m_DuplicateLineFilter.AddLine ( strText, { uiMinimumDebugLevel, ucRed, ucGreen, ucBlue } );
401+ if ( g_pGame->GetConfig ()->GetFilterDuplicateLogLinesEnabled () == false )
402+ m_DuplicateLineFilter.Flush ();
403+ UpdateLogOutput ();
404+ }
400405
401- #if 0
402- // Not sure what this is for, seems pretty useless
403- if ( m_uiHtmlLogLevel >= uiMinimumDebugLevel )
406+ void CScriptDebugging::UpdateLogOutput ( void )
407+ {
408+ SString strText;
409+ SLogData data;
410+ while ( m_DuplicateLineFilter.PopOutputLine ( strText, data ) )
404411 {
405- if ( luaVM )
412+ // Log it to the file if enough level
413+ if ( m_uiLogFileLevel >= data.uiMinimumDebugLevel )
406414 {
407- CLuaMain* pLuaMain = g_pGame->GetLuaManager()->GetVirtualMachine ( luaVM );
408- if ( pLuaMain )
409- {
410- CResourceFile * file = pLuaMain->GetResourceFile();
411- if ( file && file->GetType() == CResourceHTMLItem::RESOURCE_FILE_TYPE_HTML )
412- {
413- CResourceHTMLItem * html = (CResourceHTMLItem *)file;
414- html->AppendToPageBuffer ( strText );
415- html->AppendToPageBuffer ( "<br/>" );
416- }
417- }
415+ PrintLog ( strText );
418416 }
417+ // Log to console
418+ CLogger::LogPrintf ( " %s\n " , strText.c_str () );
419+ // Tell the players
420+ Broadcast ( CDebugEchoPacket ( strText, data.uiMinimumDebugLevel , data.ucRed , data.ucGreen , data.ucBlue ), data.uiMinimumDebugLevel );
419421 }
420- #endif
421-
422- // Tell the players
423- Broadcast ( CDebugEchoPacket ( strText, uiMinimumDebugLevel, ucRed, ucGreen, ucBlue ), uiMinimumDebugLevel );
424422}
425423
426-
427424void CScriptDebugging::PrintLog ( const char * szText )
428425{
429426 // Got a logfile?
0 commit comments