39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
/***
|
|
Copyright (C) 2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: StreamSink.hpp
|
|
Date: 2024-4-10
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#include "../AuFormatterContainer.hpp"
|
|
|
|
namespace Aurora::Logging::Sinks
|
|
{
|
|
struct StreamSink : IFormattedSink
|
|
{
|
|
StreamSink(const AuSPtr<Aurora::IO::IStreamWriter> &pPipe,
|
|
bool bText,
|
|
bool bLengthPrefixed);
|
|
|
|
void OnMessageBlocking(AuUInt8 level, const ConsoleMessage &msg) override;
|
|
bool OnMessageNonblocking(AuUInt8 level, const ConsoleMessage &msg) override;
|
|
void OnFlush() override;
|
|
|
|
private:
|
|
AuSPtr<Aurora::IO::IStreamWriter> pPipe_;
|
|
AuByteBuffer logBuffer_;
|
|
AuMutex logMutex_;
|
|
bool bLengthPrefixed_;
|
|
bool bText_;
|
|
|
|
ADD_FORMATTER_CONTAINER;
|
|
};
|
|
|
|
void NewStreamSinkRelease(IFormattedSink *pLogger);
|
|
|
|
IFormattedSink *NewStreamSinkNew(const AuSPtr<Aurora::IO::IStreamWriter> &pPipe,
|
|
bool bText,
|
|
bool bLengthPrefixed);
|
|
} |