[+] Added fmt::[...]-less logging functions for applications who do not wish to include fmtlib, for whatever reason

This commit is contained in:
Reece Wilson 2021-12-26 16:18:37 +00:00
parent 77775410ec
commit 8fe1ab04a5

View File

@ -16,26 +16,26 @@ namespace Aurora::Console::Logging
{
#if defined(_AUHAS_FMT)
template<typename ... T>
static inline void WriteLinef(const AuString &tag, const AuString &msg, T&& ... args)
static void WriteLinef(const AuString &tag, const AuString &msg, T&& ... args)
{
WriteLine(ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, std::forward<T>(args)...)));
}
template<typename ... T>
static inline void WriteLinef(EAnsiColor color, const AuString &tag, const AuString &msg, T&& ... args)
static void WriteLinef(EAnsiColor color, const AuString &tag, const AuString &msg, T&& ... args)
{
WriteLine(ConsoleMessage(color, tag, fmt::format(msg, std::forward<T>(args)...)));
}
template<typename ... T>
static inline void LogVerbose(const AuString &line, T&& ... args)
static void LogVerbose(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
}
#if defined(STAGING) || defined(DEBUG)
template<typename ... T>
static inline void LogVerboseNoShip(const AuString &line, T&& ... args)
static void LogVerboseNoShip(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
}
@ -43,46 +43,93 @@ namespace Aurora::Console::Logging
#define LogVerboseNoShip(...) DoNothing()
#endif
static inline void DoNothing()
static void DoNothing()
{
}
template<typename ... T>
static inline void LogInfo(const AuString &line, T&& ... args)
static void LogInfo(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eGreen, "Info", line, std::forward<T>(args)...);
}
template<typename ... T>
static inline void LogDbg(const AuString &line, T&& ... args)
static void LogDbg(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eYellow, "Debug", line, std::forward<T>(args)...);
}
template<typename ... T>
static inline void LogWarn(const AuString &line, T&& ... args)
static void LogWarn(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eRed, "Warn", line, std::forward<T>(args)...);
}
template<typename ... T>
static inline void LogError(const AuString &line, T&& ... args)
static void LogError(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eBoldRed, "Error", line, std::forward<T>(args)...);
}
template<typename ... T>
static inline void LogGame(const AuString &line, T&& ... args)
static void LogGame(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eBlue, "Game", line, std::forward<T>(args)...);
}
#else
static void LogVerbose(const AuString &line)
{
WriteLine(ConsoleMessage(EAnsiColor::eYellow, "Verbose", line));
}
#if defined(STAGING) || defined(DEBUG)
static void LogVerboseNoShip(const AuString &line)
{
WriteLine(ConsoleMessage(EAnsiColor::eYellow, "Verbose", line));
}
#else
#define LogVerboseNoShip(...) DoNothing()
#endif
static void DoNothing()
{
}
static void LogInfo(const AuString &line)
{
WriteLine(ConsoleMessage(EAnsiColor::eGreen, "Info", line));
}
static void LogDbg(const AuString &line)
{
WriteLine(ConsoleMessage(EAnsiColor::eYellow, "Debug", line));
}
static void LogWarn(const AuString &line)
{
WriteLine(ConsoleMessage(EAnsiColor::eRed, "Warn", line));
}
static void LogError(const AuString &line)
{
WriteLine(ConsoleMessage(EAnsiColor::eBoldRed, "Error", line));
}
static void LogGame(const AuString &line)
{
WriteLine(ConsoleMessage(EAnsiColor::eBlue, "Game", line));
}
#endif
}
#define ADD_AU_GLOBAL_ALIAS(level)\
template<typename ... T> \
static inline void AuLog ## level(T&& ... args) \
static void AuLog ## level(T&& ... args) \
{ \
Aurora::Console::Logging::Log ## level(std::forward<T>(args)...); \
}