[+] IIPCLogger structure to allow access to the underlying IPC pipe of an ipc logger

This commit is contained in:
Reece Wilson 2022-06-17 09:22:24 +01:00
parent 3985318566
commit 7432aa5cac
6 changed files with 38 additions and 8 deletions

View File

@ -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<IO::IPC::IPCPipe> ToPipe() = 0;
};
}

View File

@ -10,6 +10,7 @@
#include "ILogger.hpp"
#include "IBasicSink.hpp"
#include "IBasicSinkRB.hpp"
#include "IIPCLogger.hpp"
#include "Sinks.hpp"
namespace Aurora::Logging

View File

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

View File

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

View File

@ -21,6 +21,11 @@ namespace Aurora::Logging::Sinks
return static_cast<bool>(this->pipe_) && static_cast<bool>(this->logMutex_);
}
AuSPtr<IO::IPC::IPCPipe> 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<IPCSink *>(logger);
}

View File

@ -9,10 +9,12 @@
namespace Aurora::Logging::Sinks
{
struct IPCSink : IBasicSink
struct IPCSink : IIPCLogger
{
IPCSink(const AuSPtr<Aurora::IO::IPC::IPCPipe> &pipe);
AuSPtr<IO::IPC::IPCPipe> 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);
}