Moved logging to AzToolsFramework, working with MatEditor and SMC

Signed-off-by: Dayo Lawal <lawalfua@amazon.com>
This commit is contained in:
Dayo Lawal
2021-06-22 14:31:39 -05:00
committed by Dayo Lawal
parent b365f8bddf
commit 6f44393f3a
10 changed files with 41 additions and 107 deletions
@@ -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
@@ -1,116 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzQtComponents/Application/AzQtTraceLogger.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzFramework/Logging/LogFile.h>
namespace AzQtComponents
{
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)
{
}
AzQtTraceLogger::~AzQtTraceLogger()
{
}
void AzQtTraceLogger::WriteStartupLog(char name[])
{
m_impl->WriteStartupLog(name);
}
bool AzQtTraceLogger::Impl::OnOutput(const char* window, const char* message)
{
if (m_logFile)
{
m_logFile->AppendLog(AzFramework::LogFile::SEV_NORMAL, window, message);
}
else
{
m_startupLogSink.push_back({ window, message });
}
return false;
}
void AzQtTraceLogger::Impl::WriteStartupLog(char name[])
{
std::string temp = 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);
// 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(), name, 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();
}
*/
}
} // namespace AzQtComponents
@@ -1,33 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <AzCore/Debug/TraceMessageBus.h>
#include <AzQtComponents/AzQtComponentsAPI.h>
namespace AzQtComponents
{
class AZ_QT_COMPONENTS_API AzQtTraceLogger
{
public:
AzQtTraceLogger();
~AzQtTraceLogger();
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
};
} // 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