[*] Clean up Runtime config

[*] Refactor DirectoryLogger
This commit is contained in:
Reece Wilson 2023-07-09 21:21:49 +01:00
parent 75b71275e7
commit 3e13bd17f7
3 changed files with 21 additions and 46 deletions

View File

@ -18,8 +18,8 @@ namespace Aurora::Logging
{
AuUInt32 uMaxLogsOrZeroBeforeCompress {};
AuUInt32 uMaxLogsOrZeroBeforeDelete {};
AuUInt32 uMaxCumulativeFileSizeInMiBOrZeroBeforeDelete {};
AuUInt32 uMaxCumulativeFileSizeInMiBOrZeroBeforeCompress {};
AuUInt32 uMaxCumulativeFileSizeInMiBOrZeroBeforeDelete {};
AuUInt32 uMaxFileTimeInDeltaMSOrZeroBeforeCompress {};
AuUInt32 uMaxFileTimeInDeltaMSOrZeroBeforeDelete {};
};

View File

@ -141,34 +141,28 @@ static inline void AuDebugBreak()
namespace Aurora
{
// The following configuration structures are a mess you probably wont need to think about for a while.
// Let's assume it's safe to move onto some other for now, alright?
// Let's assume it's safe to move on for now, alright?
struct LocalLogInfo
{
bool enableLogging { true };
AuUInt32 maxSizeMB { 128 * 1024 * 1024 }; // these numbers feel insane, but at least we have a max threshold
int maxLogs { 1024 * 2 }; // by default, we neither leak disk space or waste opportunities of being able to dig through old data
int maxLogsBeforeCompress { 16 }; //
#if defined(SHIP)
bool writeLogsToUserDir { true }; // use user directory
bool bEnableLogging { true };
AuLog::DirectoryLogger defaultFileLogger
{
/* uMaxLogsOrZeroBeforeCompress */ 16, /* uMaxLogsOrZeroBeforeDelete */ 0,
/* uMaxCumulativeFileSizeInMiBOrZeroBeforeCompress*/ 0, /* uMaxCumulativeFileSizeInMiBOrZeroBeforeDelete */ 128 * 1024 * 1024,
0, 0
};
#if defined(AU_CFG_ID_SHIP)
bool bWriteLogsToUserDir { true }; // use user directory
#else
bool writeLogsToUserDir { false }; // use cwd
bool bWriteLogsToUserDir { false }; // use cwd
#endif
};
// TODO: this struct is mostly placeholder BS
struct TelemetryConfigDoc
{
LocalLogInfo localLogging;
bool enabled {false};
AuString address;
AuUInt16 port {45069};
AuString serviceIdnt {"7b5f7a54-7122-4489-ac1a-3d75884b307e"};
bool wantsActiveMonitoring {false};
bool privacyConsoleLog[255] {};
bool enabled { false };
};
struct TelemetryConfig
@ -177,15 +171,6 @@ namespace Aurora
TelemetryConfigDoc defaultConfig;
};
// TODO: this struct is mostly placeholder BS
struct SocketConsole
{
bool enableLogging {false};
bool binaryProto {false};
AuString path;
//AuIONet::ConnectionEndpoint net;
};
struct ConsoleConfig
{
/// Enables Aurora::Console::xxxStd functions; defer to enableStdXX for default logger behaviour
@ -242,28 +227,18 @@ namespace Aurora
LocalLogInfo fileConfiguration;
/// Socket config
SocketConsole socketConfiguration;
// tbd
};
struct CryptoConfig
{
/// Defer to the rationales in the implementation
/// Update 2023: world war 3 hasnt happened yet
bool allowChineseCerts {false};
/// Defer to the rationales in the implementation
/// Update 2023: spoilers it had nothing to do with the 2020 russia trolling directly, but who didn't see it coming?
bool allowRussianCerts {true};
// TODO: we have no live or cached builtin CRL and CA retrieval and storage
/// WIP
bool allowHTTPRetrievalOfCerts {true};
///
bool enablePinning {true};
///
// TODO: these placeholder bits will be made redundant once AuCrypto is overhauled
AuList<AuString> blacklistedCerts{};
AuList<AuString> whitelistedCerts{};
};
struct AsyncConfig
@ -367,9 +342,9 @@ namespace Aurora
AsyncConfig async;
FIOConfig fio;
DebugConfig debug;
ThreadingConfig threadingConfig;
bool bFIODisableBatching { true };
bool bIOLinuxHasProcIpcPerms { false };
ThreadingConfig threadingConfig;
};
/**

View File

@ -21,7 +21,7 @@ namespace Aurora::Console::ConsoleFIO
AuString path;
AuString procName;
if ((!gLogConfig.writeLogsToUserDir) || (!AuIOFS::GetProfileDomain(path)))
if ((!gLogConfig.bWriteLogsToUserDir) || (!AuIOFS::GetProfileDomain(path)))
{
path = ".";
}
@ -68,7 +68,7 @@ namespace Aurora::Console::ConsoleFIO
static bool OpenLogFile()
{
gFileSink = NewDirectorySinkUnique(GetLogDirectory(), AuLog::DirectoryLogger {(AuUInt32)gRuntimeConfig.console.fio.maxLogsBeforeCompress, (AuUInt32)gRuntimeConfig.console.fio.maxLogs, gRuntimeConfig.console.fio.maxSizeMB});
gFileSink = NewDirectorySinkUnique(GetLogDirectory(), gRuntimeConfig.console.fio.defaultFileLogger);
return static_cast<bool>(gFileSink);
}
@ -80,7 +80,7 @@ namespace Aurora::Console::ConsoleFIO
void Init()
{
if (!gLogConfig.enableLogging)
if (!gLogConfig.bEnableLogging)
{
return;
}