/*** Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: Console.cpp Date: 2021-6-8 Author: Reece ***/ #include #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> gDefaultSinks; void AddDefaultLogger(const AuSPtr &logger) { gDefaultSinks.push_back(logger); } AuSPtr CreateDefaultLogger() { return Logging::NewLoggerShared(gDefaultSinks); } static void FinailizeDefaultLogger() { gDefaultLogger = CreateDefaultLogger(); //gDefaultSinks.clear(); } AUKN_SYM AuSPtr 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(); } }