Merge pull request #3126 from aws-lumberyard-dev/Atom/guthadam/atomtools_restore_source_control_spam_filter
AtomTools: restoring log message filter to ignore source control spam
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,34 @@ namespace AzToolsFramework
|
||||
m_logFile->FlushLog();
|
||||
}
|
||||
}
|
||||
|
||||
void TraceLogger::AddWindowFilter(const AZStd::string& filter)
|
||||
{
|
||||
m_windowFilters.insert(filter);
|
||||
}
|
||||
|
||||
void TraceLogger::RemoveWindowFilter(const AZStd::string& filter)
|
||||
{
|
||||
m_windowFilters.erase(filter);
|
||||
}
|
||||
|
||||
void TraceLogger::ClearWindowFilter()
|
||||
{
|
||||
m_windowFilters.clear();
|
||||
}
|
||||
|
||||
void TraceLogger::AddMessageFilter(const AZStd::string& filter)
|
||||
{
|
||||
m_messageFilters.insert(filter);
|
||||
}
|
||||
|
||||
void TraceLogger::RemoveMessageFilter(const AZStd::string& filter)
|
||||
{
|
||||
m_messageFilters.erase(filter);
|
||||
}
|
||||
|
||||
void TraceLogger::ClearMessageFilter()
|
||||
{
|
||||
m_messageFilters.clear();
|
||||
}
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -22,8 +22,26 @@ 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);
|
||||
|
||||
//! Add filter to ignore messages for windows with matching names
|
||||
void AddWindowFilter(const AZStd::string& filter);
|
||||
|
||||
//! Remove window filter
|
||||
void RemoveWindowFilter(const AZStd::string& filter);
|
||||
|
||||
//! Clear window filters
|
||||
void ClearWindowFilter();
|
||||
|
||||
//! Add filter to ignore messages with matching names
|
||||
void AddMessageFilter(const AZStd::string& filter);
|
||||
|
||||
//! Remove message filter
|
||||
void RemoveMessageFilter(const AZStd::string& filter);
|
||||
|
||||
//! Clear message filters
|
||||
void ClearMessageFilter();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -38,6 +56,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
|
||||
|
||||
Reference in New Issue
Block a user