[*] 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 {}; 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. * @brief Constructs a UTF8 output sink.
* Backed by stdconsole; supports posix fd stdin/out localized, visual studio debugger, and conhost * Backed by stdconsole; supports posix fd stdin/out localized, visual studio debugger, and conhost
@ -53,17 +72,17 @@ namespace Aurora::Logging
/*s* /*s*
* @brief Constructs a sink of a human-readable text or binary log file * @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 * @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 * @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 * @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(NewRingLogger, IBasicSinkRB, AuUInt32 maxLogEntries);
AUKN_SHARED_API(NewStreamSink, IFormattedSink, AUKN_SHARED_API(NewStreamSink, IFormattedSink, const StreamLogger &streamLogger);
const AuSPtr<Aurora::IO::IStreamWriter> &pOutputStream,
bool bText,
bool bLengthPrefixed);
/** /**
* @brief Constructs a logger object from an array of sinks * @brief Constructs a logger object from an array of sinks

View File

@ -78,9 +78,9 @@ namespace Aurora::Logging
#endif #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) 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) AUKN_SYM void NewFileSinkRelease(IFormattedSink *pSink)
@ -99,9 +99,9 @@ namespace Aurora::Logging
Sinks::NewFileSinkRelease(pSink); 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) AUKN_SYM void NewIPCSinkRelease(IIPCLogger *pSink)
@ -120,13 +120,11 @@ namespace Aurora::Logging
Sinks::NewStreamSinkRelease(pSink); Sinks::NewStreamSinkRelease(pSink);
} }
AUKN_SYM IFormattedSink *NewStreamSinkNew(const AuSPtr<Aurora::IO::IStreamWriter> &pOutputStream, AUKN_SYM IFormattedSink *NewStreamSinkNew(const StreamLogger &streamLogger)
bool bText,
bool bLengthPrefixed)
{ {
return Sinks::NewStreamSinkNew(pOutputStream, return Sinks::NewStreamSinkNew(streamLogger.pOutputStream,
bText, streamLogger.eLogMode == ELogMode::eText,
bLengthPrefixed); streamLogger.ePrefixMode == EPrefixMode::eIncludeU32BlockLength);
} }
AUKN_SYM void NewRingLoggerRelease(IBasicSinkRB *pSink) AUKN_SYM void NewRingLoggerRelease(IBasicSinkRB *pSink)