Merge pull request #6110 from aws-lumberyard-dev/Atom/guthadam/update_trace_logger_to_clear_log

Changing trace logger to clear log file when opened
monroegm-disable-blank-issue-2
Guthrie Adams 4 years ago committed by GitHub
commit aa5563803f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -50,7 +50,7 @@ namespace AzToolsFramework
return false; return false;
} }
void TraceLogger::PrepareLogFile(const AZStd::string& logFileName) void TraceLogger::OpenLogFile(const AZStd::string& logFileName, bool clearLogFile)
{ {
using namespace AzFramework; using namespace AzFramework;
@ -73,7 +73,7 @@ namespace AzToolsFramework
AZStd::string logPath; AZStd::string logPath;
StringFunc::Path::Join(logDirectory.c_str(), logFileName.c_str(), logPath); StringFunc::Path::Join(logDirectory.c_str(), logFileName.c_str(), logPath);
m_logFile.reset(aznew LogFile(logPath.c_str())); m_logFile.reset(aznew LogFile(logPath.c_str(), clearLogFile));
if (m_logFile) if (m_logFile)
{ {
m_logFile->SetMachineReadable(false); m_logFile->SetMachineReadable(false);
@ -81,7 +81,7 @@ namespace AzToolsFramework
{ {
m_logFile->AppendLog(LogFile::SEV_NORMAL, message.window.c_str(), message.message.c_str()); m_logFile->AppendLog(LogFile::SEV_NORMAL, message.window.c_str(), message.message.c_str());
} }
m_startupLogSink = {}; m_startupLogSink.clear();
m_logFile->FlushLog(); m_logFile->FlushLog();
} }
} }

@ -23,7 +23,7 @@ namespace AzToolsFramework
~TraceLogger(); ~TraceLogger();
//! Open log file and dump log sink into it //! Open log file and dump log sink into it
void PrepareLogFile(const AZStd::string& logFileName); void OpenLogFile(const AZStd::string& logFileName, bool clearLogFile);
//! Add filter to ignore messages for windows with matching names //! Add filter to ignore messages for windows with matching names
void AddWindowFilter(const AZStd::string& filter); void AddWindowFilter(const AZStd::string& filter);
@ -55,7 +55,8 @@ namespace AzToolsFramework
AZStd::string window; AZStd::string window;
AZStd::string message; AZStd::string message;
}; };
AZStd::vector<LogMessage> m_startupLogSink;
AZStd::list<LogMessage> m_startupLogSink;
AZStd::unordered_set<AZStd::string> m_windowFilters; AZStd::unordered_set<AZStd::string> m_windowFilters;
AZStd::unordered_set<AZStd::string> m_messageFilters; AZStd::unordered_set<AZStd::string> m_messageFilters;
AZStd::unique_ptr<AzFramework::LogFile> m_logFile; AZStd::unique_ptr<AzFramework::LogFile> m_logFile;

@ -175,7 +175,8 @@ namespace AtomToolsFramework
Base::StartCommon(systemEntity); Base::StartCommon(systemEntity);
m_traceLogger.PrepareLogFile(GetBuildTargetName() + ".log"); const bool clearLogFile = GetSettingOrDefault("/O3DE/AtomToolsFramework/Application/ClearLogOnStart", false);
m_traceLogger.OpenLogFile(GetBuildTargetName() + ".log", clearLogFile);
AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusConnect(); AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusConnect();
AzToolsFramework::AssetBrowser::AssetDatabaseLocationNotificationBus::Broadcast( AzToolsFramework::AssetBrowser::AssetDatabaseLocationNotificationBus::Broadcast(

Loading…
Cancel
Save