AuroraRuntime/Source/Logging/AuFormatterContainer.hpp
Reece 85a575eb95 [+] Network interfaces API
[+] Logger IFormatter API
[*] Clean up
2022-12-14 20:08:52 +00:00

59 lines
3.3 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuFormatterContainer.hpp
Date: 2022-11-14
Author: Reece
***/
#pragma once
namespace Aurora::Logging
{
struct FormatterContainer : IFormatterContainer
{
AuSPtr<IFormatter> GetFormatter() override;
void SetFormatter(const AuSPtr<IFormatter> &pFormatter) override;
AuSPtr<IFormatter> pFormatter;
};
}
#define ADD_FORMATTER_CONTAINER \
FormatterContainer formatter; \
AuString FormatMessageHelper(AuUInt8 level, \
const ConsoleMessage &msg, \
bool bConsoleMode, \
bool bPersistentString, \
bool bSimplified) \
{ \
if (auto pFormatter = this->formatter.GetFormatter()) \
{ \
return pFormatter->Format(level, msg); \
} \
else \
{ \
if (bConsoleMode) \
{ \
return msg.ToConsole(); \
} \
\
if (bPersistentString) \
{ \
return msg.ToPersistentString(); \
} \
\
if (bSimplified) \
{ \
return msg.ToSimplified(); \
} \
\
return msg.line; \
} \
} \
AuSPtr<IFormatter> GetFormatter() override \
{ \
return this->formatter.GetFormatter(); \
} \
void SetFormatter(const AuSPtr<IFormatter> &pFormatter) override \
{ \
this->formatter.SetFormatter(pFormatter); \
}