AuroraRuntime/Source/Console/Console.cpp
Reece f717511a10 [+] NT OutputDebugStringW logger sink
[*] Split objects
[*] Consider making ABI object api boilerplate
[*] Refactor STLShims (roxtl)
2022-03-31 01:31:40 +01:00

118 lines
2.6 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Console.cpp
Date: 2021-6-8
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "Console.hpp"
#include "Commands/Commands.hpp"
#include "Hooks/Hooks.hpp"
#include "Logging/Logger.hpp"
#include "ConsoleStd/ConsoleStd.hpp"
#include "ConsoleWxWidgets/ConsoleWxWidgets.hpp"
#include "ConsoleFIO/ConsoleFIO.hpp"
#include "Flusher.hpp"
namespace Aurora::Console
{
static AuList<AuSPtr<Logging::IBasicSink>> gDefaultSinks;
void AddDefaultLogger(const AuSPtr<Logging::IBasicSink> &logger)
{
gDefaultSinks.push_back(logger);
}
AuSPtr<Logging::ILogger> CreateDefaultLogger()
{
return Logging::NewLoggerShared(gDefaultSinks);
}
static void FinailizeDefaultLogger()
{
gDefaultLogger = CreateDefaultLogger();
//gDefaultSinks.clear();
}
AUKN_SYM AuSPtr<Logging::ILogger> GetDefaultLogInterface()
{
return gDefaultLogger;
}
AUKN_SYM AuUInt32 ReadStdIn(void *buffer, AuUInt32 length)
{
return ConsoleStd::ReadStdIn(buffer, length);
}
AUKN_SYM AuUInt32 WriteStdOut(const void *buffer, AuUInt32 length)
{
return ConsoleStd::WriteStdOut(buffer, length);
}
AUKN_SYM bool DispatchRawLine(const AuString &string)
{
if (Hooks::gExternalLineProcessor)
{
Hooks::gExternalLineProcessor->OnProcessedLineUTF8(string);
return true;
}
return Commands::DispatchCommand(string);
}
void Init()
{
Hooks::Init();
ConsoleStd::Init();
ConsoleWxWidgets::Init();
#if defined(AURORA_IS_MODERNNT_DERIVED) && (defined(STAGING) || defined(DEBUG))
#if defined(STAGING)
if (IsDebuggerPresent())
{
#endif
AddDefaultLogger(NewDebugLoggerShared());
#if defined(STAGING)
}
#endif
#endif
}
void Init2()
{
ConsoleFIO::Init();
FinailizeDefaultLogger();
Logging::InitLoggers();
}
void Pump()
{
Commands::PumpCommands();
ConsoleStd::Pump();
ConsoleWxWidgets::Pump();
ConsoleFIO::Pump();
}
void Exit()
{
gDefaultSinks.clear();
gDefaultLogger.reset();
Logging::DeinitLoggers();
ConsoleFIO::Exit();
ConsoleWxWidgets::Exit();
ConsoleStd::Exit();
Hooks::Deinit();
}
AUKN_SYM void OpenLateStd()
{
ConsoleStd::Start();
FinailizeDefaultLogger();
}
AUKN_SYM void OpenLateGUI()
{
ConsoleWxWidgets::Start();
}
}