Add EditorLogger to handle logging coming from engine
This commit is contained in:
parent
72e7625900
commit
cc9c7c9157
|
|
@ -3,6 +3,7 @@
|
|||
#include <NazaraEditor/Core/Core.hpp>
|
||||
#include <NazaraEditor/Core/Application/Action.hpp>
|
||||
#include <NazaraEditor/Core/Application/BaseApplication.hpp>
|
||||
#include <NazaraEditor/Core/Application/EditorLogger.hpp>
|
||||
#include <NazaraEditor/Core/Application/Level.hpp>
|
||||
#include <NazaraEditor/Core/Components/NameComponent.hpp>
|
||||
#include <NazaraEditor/Core/UI/Window.hpp>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include <NazaraEditor/Core/Core.hpp>
|
||||
#include <Nazara/Core.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARAEDITOR_CORE_API EditorLogger
|
||||
{
|
||||
public:
|
||||
EditorLogger();
|
||||
virtual ~EditorLogger();
|
||||
|
||||
static EditorLogger* Instance();
|
||||
|
||||
void Clear() { m_text.clear(); }
|
||||
|
||||
const std::vector<std::string>& GetLog() const { return m_text; }
|
||||
|
||||
private:
|
||||
static EditorLogger* s_instance;
|
||||
std::vector<std::string> m_text;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#include <NazaraEditor/Core/Application/EditorLogger.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
EditorLogger* EditorLogger::s_instance = nullptr;
|
||||
|
||||
EditorLogger::EditorLogger()
|
||||
{
|
||||
NazaraAssert(s_instance == nullptr, "EditorLogger already exists");
|
||||
s_instance = this;
|
||||
|
||||
Nz::Log::OnLogWrite.Connect([this](auto&& str) { m_text.emplace_back(str); });
|
||||
Nz::Log::OnLogWriteError.Connect([this](ErrorType, auto&& str, int, const char*, const char*) { m_text.emplace_back(str); });
|
||||
}
|
||||
|
||||
EditorLogger::~EditorLogger()
|
||||
{
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
EditorLogger* EditorLogger::Instance()
|
||||
{
|
||||
return s_instance;
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@ int WinMain(int argc, char* argv[])
|
|||
NazaraUnused(argc);
|
||||
NazaraUnused(argv);
|
||||
|
||||
Nz::EditorLogger logger;
|
||||
NzEditor::Application app;
|
||||
|
||||
ImGui::EnsureContextOnThisThread();
|
||||
|
|
|
|||
Loading…
Reference in New Issue