diff --git a/Include/Aurora/Debug/Debug.hpp b/Include/Aurora/Debug/Debug.hpp index e034b225..3543dee5 100644 --- a/Include/Aurora/Debug/Debug.hpp +++ b/Include/Aurora/Debug/Debug.hpp @@ -24,7 +24,9 @@ namespace Aurora::Debug AUKN_SYM AuString GetLastErrorStack(); AUKN_SYM StackTrace GetLastStackTrace(); - + + AUKN_SYM StackTrace GetStackTrace(); + /** Retrieve information about the last exception.
diff --git a/Include/Aurora/Locale/LocaleStrings.hpp b/Include/Aurora/Locale/LocaleStrings.hpp index 5c109cf5..11cfff2d 100644 --- a/Include/Aurora/Locale/LocaleStrings.hpp +++ b/Include/Aurora/Locale/LocaleStrings.hpp @@ -5,11 +5,13 @@ namespace Aurora::Locale { - AUKN_SYM AuString NumbericLocaleGetDecimal(); + AUKN_SYM const AuString &NumbericLocaleGetDecimal(); - AUKN_SYM AuString TimeLocaleGetMSChar(); - AUKN_SYM AuString TimeLocaleS(); - AUKN_SYM AuString TimeLocaleGetDayChar(); + AUKN_SYM const AuString &NewLine(); + + AUKN_SYM const AuString &TimeLocaleGetMSChar(); + AUKN_SYM const AuString &TimeLocaleS(); + AUKN_SYM const AuString &TimeLocaleGetDayChar(); AUKN_SYM AuString TimeDateToString(const Time::tm &time); AUKN_SYM AuString TimeDateToISO8601(const Time::tm &time, Time::ETimezoneShift shift = Time::ETimezoneShift::eUTC); diff --git a/Source/Console/Hooks/Hooks.cpp b/Source/Console/Hooks/Hooks.cpp index ffc0159d..59ebcc00 100644 --- a/Source/Console/Hooks/Hooks.cpp +++ b/Source/Console/Hooks/Hooks.cpp @@ -37,7 +37,7 @@ namespace Aurora::Console::Hooks gExternalLineProcessor = subscriber; } - static void WriteLoggerFailedWarning() + void WriteLoggerFailedWarning() { static AuString kLoggerError = "Something went from while dispatching a log line\n"; Console::WriteStdOut(kLoggerError.data(), kLoggerError.size()); diff --git a/Source/Console/Hooks/Hooks.hpp b/Source/Console/Hooks/Hooks.hpp index 452066b9..7e456a69 100644 --- a/Source/Console/Hooks/Hooks.hpp +++ b/Source/Console/Hooks/Hooks.hpp @@ -11,6 +11,9 @@ namespace Aurora::Console::Hooks { inline AuSPtr gExternalLineProcessor; + // hack: + void WriteLoggerFailedWarning(); + void Deinit(); void Init(); void WriteLine(const ConsoleMessage &msg); diff --git a/Source/Console/Logging/Logger.cpp b/Source/Console/Logging/Logger.cpp index 7d653fd9..59873096 100644 --- a/Source/Console/Logging/Logger.cpp +++ b/Source/Console/Logging/Logger.cpp @@ -1,5 +1,6 @@ #include #include "Logger.hpp" +#include "../Hooks/Hooks.hpp" // HACK: namespace Aurora::Console::Logging { @@ -21,8 +22,39 @@ namespace Aurora::Console::Logging Disable(); } + void Logger::WriteLines(AuUInt8 level, const ConsoleMessage &msg) + { + try + { + if (msg.line.find('\n') == AuString::npos) [[likely]] + { + AddToPushQueue(level, msg); + WriteNow(level, msg); + } + else [[unlikely]] + { + Parse::SplitNewlines(msg.line, + [&](const AuString &line) + { + ConsoleMessage dup = msg; + dup.line = line; + + AddToPushQueue(level, dup); + WriteNow(level, dup); + }); + } + } + catch (...) + { + // Loggers experiencing something fucky is a liablity + Hooks::WriteLoggerFailedWarning(); + } + } + void Logger::WriteMessage(AuUInt8 level, const ConsoleMessage &msg) { + + // Accounts for atomic shutdown { AU_LOCK_GUARD(spin); @@ -32,8 +64,7 @@ namespace Aurora::Console::Logging } } - AddToPushQueue(level, msg); - WriteNow(level, msg); + WriteLines(level, msg); } void Logger::AddToPushQueue(AuUInt8 level, const ConsoleMessage &msg) diff --git a/Source/Console/Logging/Logger.hpp b/Source/Console/Logging/Logger.hpp index 0573caf0..0cdc970e 100644 --- a/Source/Console/Logging/Logger.hpp +++ b/Source/Console/Logging/Logger.hpp @@ -15,6 +15,7 @@ namespace Aurora::Console::Logging void AddToPushQueue(AuUInt8 level, const ConsoleMessage &msg); void WriteNow(AuUInt8 level, const ConsoleMessage &msg); void WriteLater(AuUInt8 level, const ConsoleMessage &msg); + void WriteLines(AuUInt8 level, const ConsoleMessage &msg); void Disable(); diff --git a/Source/Crypto/PEM/PEM.cpp b/Source/Crypto/PEM/PEM.cpp index d9c3fa0e..b28415b0 100644 --- a/Source/Crypto/PEM/PEM.cpp +++ b/Source/Crypto/PEM/PEM.cpp @@ -52,7 +52,7 @@ namespace Aurora::Crypto::PEM static AuString SerializePEM(const AuString &begin, const AuString &end, const AuByteBuffer &buf) { - auto delm = AuBuild::kCurrentVendor == AuBuild::EVendor::eGenericMicrosoft ? "\r\n" : "\n"; + auto &delm = AuLocale::NewLine(); AuString ret; ret += begin; ret += delm; diff --git a/Source/Debug/Debug.cpp b/Source/Debug/Debug.cpp index 9b92e33b..e64368bf 100644 --- a/Source/Debug/Debug.cpp +++ b/Source/Debug/Debug.cpp @@ -198,6 +198,11 @@ namespace Aurora::Debug return tlsLastStackTrace; } + AUKN_SYM StackTrace GetStackTrace() + { + return {}; + } + AUKN_SYM AuString GetLastException() { AU_LOCK_GUARD(gLock); diff --git a/Source/Locale/LocaleStrings.cpp b/Source/Locale/LocaleStrings.cpp index 6be62a11..9a32dc8b 100644 --- a/Source/Locale/LocaleStrings.cpp +++ b/Source/Locale/LocaleStrings.cpp @@ -10,24 +10,37 @@ namespace Aurora::Locale { - AUKN_SYM AuString NumbericLocaleGetDecimal() + static const AuString kDaySuffix = "d"; //for.now + static const AuString kMSSuffix = "ms"; //for.now + static const AuString kSecondSuffix = "s"; //for.now + static const AuString kDelm = "."; //for.now + static const AuString kDelmIncorrect = ","; // angry foreigner noises + + static const AuString kNewLineDelm = AuBuild::kIsNtDerived ? "\r\n" : "\n"; + + AUKN_SYM const AuString &NumbericLocaleGetDecimal() { - return "."; //for.now + return kDelm; } - AUKN_SYM AuString TimeLocaleGetDayChar() + AUKN_SYM const AuString &TimeLocaleGetDayChar() { - return "d"; //for.now + return kDaySuffix; } - AUKN_SYM AuString TimeLocaleS() + AUKN_SYM const AuString &TimeLocaleS() { - return "s"; + return kSecondSuffix; } - AUKN_SYM AuString TimeLocaleGetMSChar() + AUKN_SYM const AuString &TimeLocaleGetMSChar() { - return "ms"; //for.now + return kMSSuffix; + } + + AUKN_SYM const AuString &NewLine() + { + return kNewLineDelm; } static AuString &_TextPrepadZeroIfOne(AuString &in) diff --git a/Source/Parse/Hex.cpp b/Source/Parse/Hex.cpp index 9dad0fb0..2a2076f6 100644 --- a/Source/Parse/Hex.cpp +++ b/Source/Parse/Hex.cpp @@ -208,7 +208,7 @@ namespace Aurora::Parse in.reserve(length * 4); - const char *newLine = Aurora::Build::kCurrentVendor == Aurora::Build::EVendor::eGenericMicrosoft ? "\r\n" : "\n"; + auto &newLine = AuLocale::NewLine(); if (hexedit) {