diff --git a/Include/Aurora/Logging/IIPCLogger.hpp b/Include/Aurora/Logging/IIPCLogger.hpp new file mode 100644 index 00000000..e8473f84 --- /dev/null +++ b/Include/Aurora/Logging/IIPCLogger.hpp @@ -0,0 +1,22 @@ +/*** + Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. + + File: IIPCLogger.hpp + Date: 2022-06-17 + Author: Reece +***/ +#pragma once + +namespace Aurora::IO::IPC +{ + struct IPCPipe; +} + + +namespace Aurora::Logging +{ + struct IIPCLogger : IBasicSink + { + virtual AuSPtr ToPipe() = 0; + }; +} \ No newline at end of file diff --git a/Include/Aurora/Logging/Logging.hpp b/Include/Aurora/Logging/Logging.hpp index 5df58cbb..5a018a37 100644 --- a/Include/Aurora/Logging/Logging.hpp +++ b/Include/Aurora/Logging/Logging.hpp @@ -10,6 +10,7 @@ #include "ILogger.hpp" #include "IBasicSink.hpp" #include "IBasicSinkRB.hpp" +#include "IIPCLogger.hpp" #include "Sinks.hpp" namespace Aurora::Logging diff --git a/Include/Aurora/Logging/Sinks.hpp b/Include/Aurora/Logging/Sinks.hpp index 88093a3c..0f33d2aa 100644 --- a/Include/Aurora/Logging/Sinks.hpp +++ b/Include/Aurora/Logging/Sinks.hpp @@ -54,7 +54,7 @@ namespace Aurora::Logging /** * @brief */ - AUKN_SHARED_API(NewIPCSink, IBasicSink, const AuString &path); + AUKN_SHARED_API(NewIPCSink, IIPCLogger, const AuString &path); /** * @brief Constructs an in-memory ring buffer sink diff --git a/Source/Logging/Sinks.cpp b/Source/Logging/Sinks.cpp index b02089c9..8ba9c074 100644 --- a/Source/Logging/Sinks.cpp +++ b/Source/Logging/Sinks.cpp @@ -95,12 +95,12 @@ namespace Aurora::Logging Sinks::NewFileSinkRelease(sink); } - AUKN_SYM IBasicSink *NewIPCSinkNew(const AuString &path) + AUKN_SYM IIPCLogger *NewIPCSinkNew(const AuString &path) { return Sinks::NewIPCSinkNew(path); } - AUKN_SYM void NewIPCSinkRelease(IBasicSink *sink) + AUKN_SYM void NewIPCSinkRelease(IIPCLogger *sink) { Sinks::NewIPCSinkRelease(sink); } diff --git a/Source/Logging/Sinks/IPCSink.cpp b/Source/Logging/Sinks/IPCSink.cpp index 036873f9..160f3718 100644 --- a/Source/Logging/Sinks/IPCSink.cpp +++ b/Source/Logging/Sinks/IPCSink.cpp @@ -21,6 +21,11 @@ namespace Aurora::Logging::Sinks return static_cast(this->pipe_) && static_cast(this->logMutex_); } + AuSPtr IPCSink::ToPipe() + { + return this->pipe_; + } + void IPCSink::OnMessageBlocking(AuUInt8 level, const ConsoleMessage &msg) { AU_LOCK_GUARD(this->logMutex_); @@ -61,7 +66,7 @@ namespace Aurora::Logging::Sinks this->logBuffer_.ResetPositions(); } - IBasicSink *NewIPCSinkNew(const AuString &str) + IIPCLogger *NewIPCSinkNew(const AuString &str) { auto pipe = AuIPC::ImportPipe(str); if (!pipe) @@ -83,7 +88,7 @@ namespace Aurora::Logging::Sinks return logger; } - void NewIPCSinkRelease(IBasicSink *logger) + void NewIPCSinkRelease(IIPCLogger *logger) { AuSafeDelete(logger); } diff --git a/Source/Logging/Sinks/IPCSink.hpp b/Source/Logging/Sinks/IPCSink.hpp index 038ea166..1715fa42 100644 --- a/Source/Logging/Sinks/IPCSink.hpp +++ b/Source/Logging/Sinks/IPCSink.hpp @@ -9,10 +9,12 @@ namespace Aurora::Logging::Sinks { - struct IPCSink : IBasicSink + struct IPCSink : IIPCLogger { IPCSink(const AuSPtr &pipe); + AuSPtr ToPipe() override; + bool Init(); void OnMessageBlocking(AuUInt8 level, const ConsoleMessage &msg) override; @@ -25,6 +27,6 @@ namespace Aurora::Logging::Sinks AuThreadPrimitives::MutexUnique_t logMutex_; }; - void NewIPCSinkRelease(IBasicSink *logger); - IBasicSink *NewIPCSinkNew(const AuString &str); + void NewIPCSinkRelease(IIPCLogger *logger); + IIPCLogger *NewIPCSinkNew(const AuString &str); } \ No newline at end of file