AuroraRuntime/Include/Aurora/Console/Logging/Logging.hpp
Reece 4bd5c4604c [+] Added global AuLog[...] aliases to make the logger more bearable when I get around to finishing it
[+] Rationalize /var over /opt
[+] Ensure all users can access data under ProgramData
2021-12-24 15:49:28 +00:00

101 lines
2.7 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Logging.hpp
Date: 2021-9-21
Author: Reece
***/
#pragma once
#include "ILogger.hpp"
#include "IBasicSink.hpp"
#include "IBasicSinkRB.hpp"
#include "Sinks.hpp"
namespace Aurora::Console::Logging
{
#if defined(_AUHAS_FMT)
template<typename ... T>
static inline 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)
{
WriteLine(ConsoleMessage(color, tag, fmt::format(msg, std::forward<T>(args)...)));
}
template<typename ... T>
static inline 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)
{
WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
}
#else
#define LogVerboseNoShip(...) DoNothing()
#endif
static inline void DoNothing()
{
}
template<typename ... T>
static inline 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)
{
WriteLinef(EAnsiColor::eYellow, "Debug", line, std::forward<T>(args)...);
}
template<typename ... T>
static inline 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)
{
WriteLinef(EAnsiColor::eBoldRed, "Error", line, std::forward<T>(args)...);
}
template<typename ... T>
static inline void LogGame(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eBlue, "Game", line, std::forward<T>(args)...);
}
#endif
}
#define ADD_AU_GLOBAL_ALIAS(level)\
template<typename ... T> \
static inline void AuLog ## level(T&& ... args) \
{ \
Aurora::Console::Logging::Log ## level(std::forward<T>(args)...); \
}
ADD_AU_GLOBAL_ALIAS(Info)
ADD_AU_GLOBAL_ALIAS(Dbg)
ADD_AU_GLOBAL_ALIAS(Warn)
ADD_AU_GLOBAL_ALIAS(Error)
ADD_AU_GLOBAL_ALIAS(Game)
ADD_AU_GLOBAL_ALIAS(Verbose)
#if defined(STAGING) || defined(DEBUG)
ADD_AU_GLOBAL_ALIAS(VerboseNoShip)
#else
#define AuLogVerboseNoShip(...)
#endif