AuroraRuntime/Include/Aurora/Console/Logging/ILogger.hpp

99 lines
3.3 KiB
C++
Raw Normal View History

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ILogger.hpp
Date: 2021-11-1
Author: Reece
***/
#pragma once
namespace Aurora::Console::Logging
{
enum class ELogLevel
{
eZero = 0,
eInfo = 0,
eVerbose,
eError,
eDebug,
eWarn
};
static auto const kLogLevelDefault = static_cast<AuUInt8>(ELogLevel::eZero);
static auto const kLogLevelUsr = static_cast<AuUInt8>(ELogLevel::eWarn);
static auto const kLogLevelMax = 16;
struct ILogger
{
virtual void WriteMessage(AuUInt8 level, const ConsoleMessage &msg) = 0;
virtual void PushFilter(AuUInt8 level, bool shouldFilter) = 0;
virtual void PopFilter() = 0;
#if defined(_AUHAS_FMT)
template<typename ... T>
inline void WriteLinef(AuUInt8 level, const AuString &tag, const AuString &msg, T&& ... args)
{
WriteMessage(level, ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, std::forward<T>(args)...)));
}
template<typename ... T>
inline void WriteLinef(AuUInt8 level, EAnsiColor color, const AuString &tag, const AuString &msg, T&& ... args)
{
WriteMessage(level, ConsoleMessage(color, tag, fmt::format(msg, std::forward<T>(args)...)));
}
template<typename ... T>
inline void LogVerbose(const AuString &line, T&& ... args)
{
WriteLinef(static_cast<AuUInt8>(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
}
#if defined(STAGING) || defined(DEBUG)
template<typename ... T>
inline void LogVerboseNoShip(const AuString &line, T&& ... args)
{
WriteLinef(static_cast<AuUInt8>(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
}
#else
template<typename ... T>
inline void LogVerboseNoShip(const AuString &line, T&& ... args)
{}
#endif
inline void DoNothing()
{
}
template<typename ... T>
inline void LogInfo(const AuString &line, T&& ... args)
{
WriteLinef(static_cast<AuUInt8>(ELogLevel::eInfo), EAnsiColor::eGreen, "Info", line, std::forward<T>(args)...);
}
template<typename ... T>
inline void LogDbg(const AuString &line, T&& ... args)
{
WriteLinef(static_cast<AuUInt8>(ELogLevel::eDebug), EAnsiColor::eYellow, "Debug", line, std::forward<T>(args)...);
}
template<typename ... T>
inline void LogWarn(const AuString &line, T&& ... args)
{
WriteLinef(static_cast<AuUInt8>(ELogLevel::eWarn), EAnsiColor::eRed, "Warn", line, std::forward<T>(args)...);
}
template<typename ... T>
inline void LogError(const AuString &line, T&& ... args)
{
WriteLinef(static_cast<AuUInt8>(ELogLevel::eError), EAnsiColor::eBoldRed, "Error", line, std::forward<T>(args)...);
}
template<typename ... T>
inline void LogGame(const AuString &line, T&& ... args)
{
WriteLinef(static_cast<AuUInt8>(ELogLevel::eVerbose), EAnsiColor::eBlue, "Game", line, std::forward<T>(args)...);
}
#endif
};
}