[*] Destink Stinks.hpp

This commit is contained in:
Reece Wilson 2024-04-11 14:53:02 +01:00
parent c6a1eb3f1e
commit f2eadb4653
2 changed files with 33 additions and 19 deletions

View File

@ -29,6 +29,25 @@ namespace Aurora::Logging
AuUInt32 uMaxFileTimeInDeltaMSOrZeroBeforeDelete {};
};
AUE_DEFINE(ELogMode,
(
eText,
eBinary
));
AUE_DEFINE(EPrefixMode,
(
eNoPrefix,
eIncludeU32BlockLength
));
struct StreamLogger
{
EPrefixMode ePrefixMode { EPrefixMode::eNoPrefix };
ELogMode eLogMode { ELogMode::eText };
AuSPtr<Aurora::IO::IStreamWriter> pOutputStream;
};
/**
* @brief Constructs a UTF8 output sink.
* Backed by stdconsole; supports posix fd stdin/out localized, visual studio debugger, and conhost
@ -53,17 +72,17 @@ namespace Aurora::Logging
/*s*
* @brief Constructs a sink of a human-readable text or binary log file
*/
AUKN_SHARED_API(NewFileSink, IFormattedSink, const AuString &path, bool bBinary = false);
AUKN_SHARED_API(NewFileSink, IFormattedSink, const AuString &path, ELogMode eMode = ELogMode::eText);
/**
* @brief Constructs a dedicated log directory subject to erasure as defined by defined DirectoryLogger
*/
AUKN_SHARED_API(NewDirectorySink, IBasicSink, const AuString &path, DirectoryLogger dirInfo, bool bBinary = false);
AUKN_SHARED_API(NewDirectorySink, IBasicSink, const AuString &path, DirectoryLogger dirInfo, ELogMode eMode = ELogMode::eText);
/**
* @brief
*/
AUKN_SHARED_API(NewIPCSink, IIPCLogger, const AuString &path, bool bLengthPrefixedStream = false);
AUKN_SHARED_API(NewIPCSink, IIPCLogger, const AuString &path, EPrefixMode ePrefixMode = EPrefixMode::eNoPrefix);
/**
* @brief Constructs an in-memory ring buffer sink
@ -71,10 +90,7 @@ namespace Aurora::Logging
AUKN_SHARED_API(NewRingLogger, IBasicSinkRB, AuUInt32 maxLogEntries);
AUKN_SHARED_API(NewStreamSink, IFormattedSink,
const AuSPtr<Aurora::IO::IStreamWriter> &pOutputStream,
bool bText,
bool bLengthPrefixed);
AUKN_SHARED_API(NewStreamSink, IFormattedSink, const StreamLogger &streamLogger);
/**
* @brief Constructs a logger object from an array of sinks

View File

@ -78,9 +78,9 @@ namespace Aurora::Logging
#endif
}
AUKN_SYM IBasicSink *NewDirectorySinkNew(const AuString &path, DirectoryLogger dirInfo, bool bBinary)
AUKN_SYM IBasicSink *NewDirectorySinkNew(const AuString &path, DirectoryLogger dirInfo, ELogMode eMode)
{
return Sinks::NewDirectoryLoggerNew(path, dirInfo, bBinary);
return Sinks::NewDirectoryLoggerNew(path, dirInfo, eMode == ELogMode::eBinary);
}
AUKN_SYM void NewDirectorySinkRelease(IBasicSink *pSink)
@ -89,9 +89,9 @@ namespace Aurora::Logging
}
AUKN_SYM IFormattedSink *NewFileSinkNew(const AuString &path, bool bBinary)
AUKN_SYM IFormattedSink *NewFileSinkNew(const AuString &path, ELogMode eMode)
{
return Sinks::NewFileSinkNew(path, bBinary);
return Sinks::NewFileSinkNew(path, eMode == ELogMode::eBinary);
}
AUKN_SYM void NewFileSinkRelease(IFormattedSink *pSink)
@ -99,9 +99,9 @@ namespace Aurora::Logging
Sinks::NewFileSinkRelease(pSink);
}
AUKN_SYM IIPCLogger *NewIPCSinkNew(const AuString &path, bool lengthPrefixed)
AUKN_SYM IIPCLogger *NewIPCSinkNew(const AuString &path, EPrefixMode ePrefixMode)
{
return Sinks::NewIPCSinkNew(path, lengthPrefixed);
return Sinks::NewIPCSinkNew(path, ePrefixMode == EPrefixMode::eIncludeU32BlockLength);
}
AUKN_SYM void NewIPCSinkRelease(IIPCLogger *pSink)
@ -120,13 +120,11 @@ namespace Aurora::Logging
Sinks::NewStreamSinkRelease(pSink);
}
AUKN_SYM IFormattedSink *NewStreamSinkNew(const AuSPtr<Aurora::IO::IStreamWriter> &pOutputStream,
bool bText,
bool bLengthPrefixed)
AUKN_SYM IFormattedSink *NewStreamSinkNew(const StreamLogger &streamLogger)
{
return Sinks::NewStreamSinkNew(pOutputStream,
bText,
bLengthPrefixed);
return Sinks::NewStreamSinkNew(streamLogger.pOutputStream,
streamLogger.eLogMode == ELogMode::eText,
streamLogger.ePrefixMode == EPrefixMode::eIncludeU32BlockLength);
}
AUKN_SYM void NewRingLoggerRelease(IBasicSinkRB *pSink)