AtomTools: restoring log message filter to ignore source control spam
Added message filter support to TraceLogger Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
@@ -5,11 +5,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzToolsFramework/Logger/TraceLogger.h>
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
|
||||
#include <AzToolsFramework/Logger/TraceLogger.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -25,6 +23,22 @@ namespace AzToolsFramework
|
||||
|
||||
bool TraceLogger::OnOutput(const char* window, const char* message)
|
||||
{
|
||||
for (const auto& filter : m_windowFilters)
|
||||
{
|
||||
if (AZ::StringFunc::Contains(window, filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& filter : m_messageFilters)
|
||||
{
|
||||
if (AZ::StringFunc::Contains(message, filter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_logFile)
|
||||
{
|
||||
m_logFile->AppendLog(AzFramework::LogFile::SEV_NORMAL, window, message);
|
||||
@@ -36,10 +50,10 @@ namespace AzToolsFramework
|
||||
return false;
|
||||
}
|
||||
|
||||
void TraceLogger::WriteStartupLog(const AZStd::string& logFileName)
|
||||
{
|
||||
void TraceLogger::PrepareLogFile(const AZStd::string& logFileName)
|
||||
{
|
||||
using namespace AzFramework;
|
||||
|
||||
|
||||
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
|
||||
AZ_Assert(fileIO != nullptr, "FileIO should be running at this point");
|
||||
|
||||
@@ -71,4 +85,14 @@ namespace AzToolsFramework
|
||||
m_logFile->FlushLog();
|
||||
}
|
||||
}
|
||||
|
||||
void TraceLogger::AddWindowFilter(const AZStd::string& filter)
|
||||
{
|
||||
m_windowFilters.insert(filter);
|
||||
}
|
||||
|
||||
void TraceLogger::AddMessageFilter(const AZStd::string& filter)
|
||||
{
|
||||
m_messageFilters.insert(filter);
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -22,8 +22,14 @@ namespace AzToolsFramework
|
||||
TraceLogger();
|
||||
~TraceLogger();
|
||||
|
||||
//! Intalize logging for O3DEToolsApplications
|
||||
void WriteStartupLog(const AZStd::string& logFileName);
|
||||
//! Open log file and dump log sink into it
|
||||
void PrepareLogFile(const AZStd::string& logFileName);
|
||||
|
||||
//! Ignore messages sent to windowd with names matching filter
|
||||
void AddWindowFilter(const AZStd::string& filter);
|
||||
|
||||
//! Ignore messages with text matching filter
|
||||
void AddMessageFilter(const AZStd::string& filter);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -38,6 +44,8 @@ namespace AzToolsFramework
|
||||
AZStd::string message;
|
||||
};
|
||||
AZStd::vector<LogMessage> m_startupLogSink;
|
||||
AZStd::unordered_set<AZStd::string> m_windowFilters;
|
||||
AZStd::unordered_set<AZStd::string> m_messageFilters;
|
||||
AZStd::unique_ptr<AzFramework::LogFile> m_logFile;
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
|
||||
#include <Atom/RPI.Edit/Common/AssetUtils.h>
|
||||
#include <Atom/RPI.Public/RPISystemInterface.h>
|
||||
|
||||
#include <AtomToolsFramework/Util/Util.h>
|
||||
#include <AtomToolsFramework/Application/AtomToolsApplication.h>
|
||||
#include <AtomToolsFramework/Util/Util.h>
|
||||
#include <AtomToolsFramework/Window/AtomToolsMainWindowFactoryRequestBus.h>
|
||||
#include <AtomToolsFramework/Window/AtomToolsMainWindowRequestBus.h>
|
||||
|
||||
#include <AzCore/IO/Path/Path.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
#include <AzFramework/Asset/AssetSystemComponent.h>
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
#include <AzFramework/Network/AssetProcessorConnection.h>
|
||||
@@ -66,6 +66,9 @@ namespace AtomToolsFramework
|
||||
this->PumpSystemEventLoopUntilEmpty();
|
||||
this->Tick();
|
||||
});
|
||||
|
||||
// Suppress spam from the Source Control system
|
||||
m_traceLogger.AddWindowFilter(AzToolsFramework::SCC_WINDOW);
|
||||
}
|
||||
|
||||
AtomToolsApplication ::~AtomToolsApplication()
|
||||
@@ -396,7 +399,7 @@ namespace AtomToolsFramework
|
||||
|
||||
AZStd::string fileName = GetBuildTargetName() + ".log";
|
||||
|
||||
m_traceLogger.WriteStartupLog(fileName.c_str());
|
||||
m_traceLogger.PrepareLogFile(fileName.c_str());
|
||||
|
||||
if (!LaunchDiscoveryService())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user