33 lines
961 B
C++
33 lines
961 B
C++
/***
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: IPCSink.hpp
|
|
Date: 2022-6-16
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
namespace Aurora::Logging::Sinks
|
|
{
|
|
struct IPCSink : IIPCLogger
|
|
{
|
|
IPCSink(const AuSPtr<Aurora::IO::IPC::IPCPipe> &pipe, bool lengthPrefixed);
|
|
|
|
AuSPtr<IO::IPC::IPCPipe> ToPipe() override;
|
|
|
|
bool Init();
|
|
|
|
void OnMessageBlocking(AuUInt8 level, const ConsoleMessage &msg) override;
|
|
bool OnMessageNonblocking(AuUInt8 level, const ConsoleMessage &msg) override;
|
|
void OnFlush() override;
|
|
|
|
private:
|
|
AuSPtr<Aurora::IO::IPC::IPCPipe> pPipe_;
|
|
AuByteBuffer logBuffer_;
|
|
AuThreadPrimitives::Mutex logMutex_;
|
|
bool bLengthPrefixed_;
|
|
};
|
|
|
|
void NewIPCSinkRelease(IIPCLogger *logger);
|
|
IIPCLogger *NewIPCSinkNew(const AuString &str, bool lengthPrefixed);
|
|
} |