59 lines
3.3 KiB
C++
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); \
|
|
} |