[+] Added LocaleStrings.hpp -> NewLine

[*] LocaleStrings should always return constant references
[*] Readded line splitting logic to the new Logger class
This commit is contained in:
Reece Wilson 2022-01-26 08:30:19 +00:00
parent 0bcc0aa508
commit fbd437d3d4
10 changed files with 75 additions and 18 deletions

View File

@ -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. <br>

View File

@ -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);

View File

@ -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());

View File

@ -11,6 +11,9 @@ namespace Aurora::Console::Hooks
{
inline AuSPtr<Hooks::ITextLineSubscriber> gExternalLineProcessor;
// hack:
void WriteLoggerFailedWarning();
void Deinit();
void Init();
void WriteLine(const ConsoleMessage &msg);

View File

@ -1,5 +1,6 @@
#include <Source/RuntimeInternal.hpp>
#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)

View File

@ -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();

View File

@ -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;

View File

@ -198,6 +198,11 @@ namespace Aurora::Debug
return tlsLastStackTrace;
}
AUKN_SYM StackTrace GetStackTrace()
{
return {};
}
AUKN_SYM AuString GetLastException()
{
AU_LOCK_GUARD(gLock);

View File

@ -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)

View File

@ -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)
{