[+] IIPCLogger structure to allow access to the underlying IPC pipe of an ipc logger
This commit is contained in:
parent
3985318566
commit
7432aa5cac
22
Include/Aurora/Logging/IIPCLogger.hpp
Normal file
22
Include/Aurora/Logging/IIPCLogger.hpp
Normal 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;
|
||||
};
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
#include "ILogger.hpp"
|
||||
#include "IBasicSink.hpp"
|
||||
#include "IBasicSinkRB.hpp"
|
||||
#include "IIPCLogger.hpp"
|
||||
#include "Sinks.hpp"
|
||||
|
||||
namespace Aurora::Logging
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user