Moved logging to AzToolsFramework, working with MatEditor and SMC
Signed-off-by: Dayo Lawal <lawalfua@amazon.com>
This commit is contained in:
@@ -20,7 +20,6 @@ namespace AzQtComponents
|
||||
|
||||
AzQtApplication::AzQtApplication(int& argc, char** argv)
|
||||
: QApplication(argc, argv)
|
||||
, m_traceLogger(new AzQtTraceLogger)
|
||||
{
|
||||
// Use a common Qt settings path for applications that don't register their own application name
|
||||
if (QApplication::applicationName().isEmpty())
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <AzQtComponents/Application/AzQtTraceLogger.h>
|
||||
#include <AzQtComponents/Utilities/HandleDpiAwareness.h>
|
||||
|
||||
namespace AzQtComponents
|
||||
@@ -27,9 +26,6 @@ namespace AzQtComponents
|
||||
void static setDpiScaling();
|
||||
|
||||
protected:
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZStd::unique_ptr<AzQtTraceLogger> m_traceLogger;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
};
|
||||
|
||||
} // namespace AzQtComponents
|
||||
|
||||
@@ -9,8 +9,6 @@ set(FILES
|
||||
AzQtComponentsAPI.h
|
||||
Application/AzQtApplication.cpp
|
||||
Application/AzQtApplication.h
|
||||
Application/AzQtTraceLogger.cpp
|
||||
Application/AzQtTraceLogger.h
|
||||
Buses/DragAndDrop.h
|
||||
Buses/ShortcutDispatch.h
|
||||
DragAndDrop/MainWindowDragAndDrop.h
|
||||
|
||||
+12
-49
@@ -10,59 +10,25 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzQtComponents/Application/AzQtTraceLogger.h>
|
||||
#include <AzToolsFramework/Logger/AzQtTraceLogger.h>
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzFramework/Logging/LogFile.h>
|
||||
|
||||
namespace AzQtComponents
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
class AzQtTraceLogger::Impl : public AZ::Debug::TraceMessageBus::Handler
|
||||
{
|
||||
public:
|
||||
void WriteStartupLog(char name[]);
|
||||
|
||||
Impl()
|
||||
{
|
||||
AZ::Debug::TraceMessageBus::Handler::BusConnect();
|
||||
}
|
||||
~Impl()
|
||||
{
|
||||
AZ::Debug::TraceMessageBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AZ::Debug::TraceMessageBus::Handler overrides...
|
||||
bool OnOutput(const char* window, const char* message) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct LogMessage
|
||||
{
|
||||
public:
|
||||
AZStd::string window;
|
||||
AZStd::string message;
|
||||
};
|
||||
AZStd::vector<LogMessage> m_startupLogSink;
|
||||
AZStd::unique_ptr<AzFramework::LogFile> m_logFile;
|
||||
};
|
||||
|
||||
AzQtTraceLogger::AzQtTraceLogger()
|
||||
: m_impl(new Impl)
|
||||
{
|
||||
AZ::Debug::TraceMessageBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
AzQtTraceLogger::~AzQtTraceLogger()
|
||||
{
|
||||
AZ::Debug::TraceMessageBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void AzQtTraceLogger::WriteStartupLog(char name[])
|
||||
{
|
||||
m_impl->WriteStartupLog(name);
|
||||
}
|
||||
|
||||
bool AzQtTraceLogger::Impl::OnOutput(const char* window, const char* message)
|
||||
bool AzQtTraceLogger::OnOutput(const char* window, const char* message)
|
||||
{
|
||||
if (m_logFile)
|
||||
{
|
||||
@@ -75,15 +41,13 @@ namespace AzQtComponents
|
||||
return false;
|
||||
}
|
||||
|
||||
void AzQtTraceLogger::Impl::WriteStartupLog(char name[])
|
||||
{
|
||||
std::string temp = name;
|
||||
|
||||
//using namespace AzFramework;
|
||||
///*
|
||||
void AzQtTraceLogger::WriteStartupLog(char name[])
|
||||
{
|
||||
using namespace AzFramework;
|
||||
|
||||
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
|
||||
AZ_Assert(fileIO != nullptr, "FileIO should be running at this point");
|
||||
/*
|
||||
|
||||
// There is no log system online so we have to create your own log file.
|
||||
char resolveBuffer[AZ_MAX_PATH_LEN] = { 0 };
|
||||
fileIO->ResolvePath("@user@", resolveBuffer, AZ_MAX_PATH_LEN);
|
||||
@@ -111,6 +75,5 @@ namespace AzQtComponents
|
||||
m_startupLogSink = {};
|
||||
m_logFile->FlushLog();
|
||||
}
|
||||
*/
|
||||
}
|
||||
} // namespace AzQtComponents
|
||||
} // namespace AzToolsFramework
|
||||
+17
-8
@@ -13,11 +13,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Debug/TraceMessageBus.h>
|
||||
#include <AzQtComponents/AzQtComponentsAPI.h>
|
||||
#include <AzFramework/Logging/LogFile.h>
|
||||
|
||||
namespace AzQtComponents
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
class AZ_QT_COMPONENTS_API AzQtTraceLogger
|
||||
class AzQtTraceLogger : public AZ::Debug::TraceMessageBus::Handler
|
||||
{
|
||||
public:
|
||||
AzQtTraceLogger();
|
||||
@@ -25,9 +25,18 @@ namespace AzQtComponents
|
||||
void WriteStartupLog(char name[]);
|
||||
|
||||
protected:
|
||||
class Impl;
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
AZStd::unique_ptr<Impl> m_impl;
|
||||
AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AZ::Debug::TraceMessageBus::Handler overrides...
|
||||
bool OnOutput(const char* window, const char* message) override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct LogMessage
|
||||
{
|
||||
public:
|
||||
AZStd::string window;
|
||||
AZStd::string message;
|
||||
};
|
||||
AZStd::vector<LogMessage> m_startupLogSink;
|
||||
AZStd::unique_ptr<AzFramework::LogFile> m_logFile;
|
||||
};
|
||||
} // namespace AzQtComponents
|
||||
} // namespace AzToolsFramework
|
||||
@@ -147,6 +147,8 @@ set(FILES
|
||||
Entity/SliceEditorEntityOwnershipServiceBus.h
|
||||
Fingerprinting/TypeFingerprinter.h
|
||||
Fingerprinting/TypeFingerprinter.cpp
|
||||
Logger/AzQtTraceLogger.cpp
|
||||
Logger/AzQtTraceLogger.h
|
||||
Manipulators/AngularManipulator.cpp
|
||||
Manipulators/AngularManipulator.h
|
||||
Manipulators/BaseManipulator.cpp
|
||||
|
||||
@@ -352,43 +352,7 @@ namespace MaterialEditor
|
||||
ExitMainLoop();
|
||||
}
|
||||
}
|
||||
/*
|
||||
void MaterialEditorApplication::WriteStartupLog()
|
||||
{
|
||||
using namespace AzFramework;
|
||||
|
||||
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
|
||||
AZ_Assert(fileIO != nullptr, "FileIO should be running at this point");
|
||||
|
||||
// There is no log system online so we have to create your own log file.
|
||||
char resolveBuffer[AZ_MAX_PATH_LEN] = { 0 };
|
||||
fileIO->ResolvePath("@user@", resolveBuffer, AZ_MAX_PATH_LEN);
|
||||
|
||||
// Note: @log@ hasn't been set at this point
|
||||
AZStd::string logDirectory;
|
||||
StringFunc::Path::Join(resolveBuffer, "log", logDirectory);
|
||||
fileIO->SetAlias("@log@", logDirectory.c_str());
|
||||
|
||||
fileIO->CreatePath("@root@");
|
||||
fileIO->CreatePath("@user@");
|
||||
fileIO->CreatePath("@log@");
|
||||
|
||||
AZStd::string logPath;
|
||||
StringFunc::Path::Join(logDirectory.c_str(), "MaterialEditor.log", logPath);
|
||||
|
||||
m_logFile.reset(aznew LogFile(logPath.c_str()));
|
||||
if (m_logFile)
|
||||
{
|
||||
m_logFile->SetMachineReadable(false);
|
||||
for (const LogMessage& message : m_startupLogSink)
|
||||
{
|
||||
m_logFile->AppendLog(LogFile::SEV_NORMAL, message.window.c_str(), message.message.c_str());
|
||||
}
|
||||
m_startupLogSink = {};
|
||||
m_logFile->FlushLog();
|
||||
}
|
||||
}
|
||||
*/
|
||||
void MaterialEditorApplication::LoadSettings()
|
||||
{
|
||||
AZ::SerializeContext* context = nullptr;
|
||||
@@ -476,8 +440,7 @@ namespace MaterialEditor
|
||||
return;
|
||||
}
|
||||
|
||||
m_traceLogger->WriteStartupLog("MaterialEditor.log");
|
||||
//WriteStartupLog();
|
||||
m_traceLogger.WriteStartupLog("MaterialEditor.log");
|
||||
|
||||
if (!LaunchDiscoveryService())
|
||||
{
|
||||
|
||||
@@ -20,9 +20,8 @@
|
||||
#include <AzFramework/Logging/LogFile.h>
|
||||
#include <AzToolsFramework/API/AssetDatabaseBus.h>
|
||||
#include <AzToolsFramework/API/EditorPythonConsoleBus.h>
|
||||
|
||||
#include <AzToolsFramework/Logger/AzQtTraceLogger.h>
|
||||
#include <AzQtComponents/Application/AzQtApplication.h>
|
||||
#include <AzQtComponents/Application/AzQtTraceLogger.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
@@ -106,7 +105,6 @@ namespace MaterialEditor
|
||||
void CompileCriticalAssets();
|
||||
|
||||
void ProcessCommandLine(const AZ::CommandLine& commandLine);
|
||||
//void WriteStartupLog();
|
||||
|
||||
void LoadSettings();
|
||||
void UnloadSettings();
|
||||
@@ -126,6 +124,8 @@ namespace MaterialEditor
|
||||
AZStd::vector<LogMessage> m_startupLogSink;
|
||||
AZStd::unique_ptr<AzFramework::LogFile> m_logFile;
|
||||
|
||||
AzToolsFramework::AzQtTraceLogger m_traceLogger;
|
||||
|
||||
//! Local user settings are used to store material browser tree expansion state
|
||||
AZ::UserSettingsProvider m_localUserSettings;
|
||||
|
||||
|
||||
+2
-2
@@ -39,8 +39,6 @@
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
#include <AzQtComponents/Application/AzQtTraceLogger.h>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
|
||||
#include <QFileInfo>
|
||||
#include <QObject>
|
||||
@@ -345,6 +343,8 @@ namespace ShaderManagementConsole
|
||||
return;
|
||||
}
|
||||
|
||||
m_traceLogger.WriteStartupLog("ShaderManagementConsole.log");
|
||||
|
||||
//[GFX TODO][ATOM-415] Try to factor out some of this stuff with AtomSampleViewerApplication
|
||||
AzToolsFramework::AssetDatabase::AssetDatabaseRequestsBus::Handler::BusConnect();
|
||||
AzToolsFramework::AssetBrowser::AssetDatabaseLocationNotificationBus::Broadcast(&AzToolsFramework::AssetBrowser::AssetDatabaseLocationNotifications::OnDatabaseInitialized);
|
||||
|
||||
+4
@@ -18,11 +18,13 @@
|
||||
|
||||
#include <AzToolsFramework/API/AssetDatabaseBus.h>
|
||||
#include <AzToolsFramework/API/EditorPythonConsoleBus.h>
|
||||
#include <AzToolsFramework/Logger/AzQtTraceLogger.h>
|
||||
|
||||
#include <Atom/Document/ShaderManagementConsoleDocumentSystemRequestBus.h>
|
||||
#include <Atom/Window/ShaderManagementConsoleWindowNotificationBus.h>
|
||||
|
||||
#include <AzQtComponents/Application/AzQtApplication.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
namespace ShaderManagementConsole
|
||||
@@ -113,6 +115,8 @@ namespace ShaderManagementConsole
|
||||
|
||||
static void PyIdleWaitFrames(uint32_t frames);
|
||||
|
||||
AzToolsFramework::AzQtTraceLogger m_traceLogger;
|
||||
|
||||
//! Local user settings are used to store asset browser tree expansion state
|
||||
AZ::UserSettingsProvider m_localUserSettings;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user