2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: Logging.hpp
|
2021-11-05 17:34:23 +00:00
|
|
|
Date: 2021-9-21
|
2021-06-27 21:25:29 +00:00
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
#include "ILogger.hpp"
|
|
|
|
#include "IBasicSink.hpp"
|
|
|
|
#include "IBasicSinkRB.hpp"
|
|
|
|
#include "Sinks.hpp"
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
namespace Aurora::Console::Logging
|
|
|
|
{
|
2021-09-06 10:58:08 +00:00
|
|
|
#if defined(_AUHAS_FMT)
|
2022-01-21 22:37:29 +00:00
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
template<typename ... T>
|
2022-01-21 22:37:29 +00:00
|
|
|
inline void WriteLinef(AuUInt8 level, const AuString &tag, const AuString &msg, T&& ... args)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLine(level, ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, AuForward<T>(args)...)));
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename ... T>
|
2022-01-21 22:37:29 +00:00
|
|
|
inline void WriteLinef(AuUInt8 level, EAnsiColor color, const AuString &tag, const AuString &msg, T&& ... args)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLine(level, ConsoleMessage(color, tag, fmt::format(msg, AuForward<T>(args)...)));
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2022-01-21 22:37:29 +00:00
|
|
|
|
2021-10-21 15:01:48 +00:00
|
|
|
template<typename ... T>
|
2022-01-21 22:37:29 +00:00
|
|
|
inline void LogVerbose(const AuString &line, T&& ... args)
|
2021-10-21 15:01:48 +00:00
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLinef(static_cast<AuUInt8>(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, AuForward<T>(args)...);
|
2021-10-21 15:01:48 +00:00
|
|
|
}
|
2022-01-21 22:37:29 +00:00
|
|
|
|
2021-10-21 15:01:48 +00:00
|
|
|
#if defined(STAGING) || defined(DEBUG)
|
|
|
|
template<typename ... T>
|
2022-01-21 22:37:29 +00:00
|
|
|
inline auline void LogVerboseNoShip(const AuString &line, T&& ... args)
|
2021-10-21 15:01:48 +00:00
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLinef(static_cast<AuUInt8>(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, AuForward<T>(args)...);
|
2021-10-21 15:01:48 +00:00
|
|
|
}
|
|
|
|
#else
|
2022-01-21 22:37:29 +00:00
|
|
|
template<typename ... T>
|
|
|
|
inline auline void LogVerboseNoShip(const AuString &line, T&& ... args)
|
|
|
|
{}
|
2021-10-21 15:01:48 +00:00
|
|
|
#endif
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2022-01-21 22:37:29 +00:00
|
|
|
inline void DoNothing()
|
2021-11-05 17:34:23 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
template<typename ... T>
|
2022-01-21 22:37:29 +00:00
|
|
|
inline void LogInfo(const AuString &line, T&& ... args)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLinef(static_cast<AuUInt8>(ELogLevel::eInfo), EAnsiColor::eGreen, "Info", line, AuForward<T>(args)...);
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename ... T>
|
2022-01-21 22:37:29 +00:00
|
|
|
inline void LogDbg(const AuString &line, T&& ... args)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLinef(static_cast<AuUInt8>(ELogLevel::eDebug), EAnsiColor::eYellow, "Debug", line, AuForward<T>(args)...);
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename ... T>
|
2022-01-21 22:37:29 +00:00
|
|
|
inline void LogWarn(const AuString &line, T&& ... args)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLinef(static_cast<AuUInt8>(ELogLevel::eWarn), EAnsiColor::eRed, "Warn", line, AuForward<T>(args)...);
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 15:01:48 +00:00
|
|
|
template<typename ... T>
|
2022-01-21 22:37:29 +00:00
|
|
|
inline void LogError(const AuString &line, T&& ... args)
|
2021-10-21 15:01:48 +00:00
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLinef(static_cast<AuUInt8>(ELogLevel::eError), EAnsiColor::eBoldRed, "Error", line, AuForward<T>(args)...);
|
2021-10-21 15:01:48 +00:00
|
|
|
}
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
template<typename ... T>
|
2022-01-21 22:37:29 +00:00
|
|
|
inline void LogGame(const AuString &line, T&& ... args)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLinef(static_cast<AuUInt8>(ELogLevel::eVerbose), EAnsiColor::eBlue, "Game", line, AuForward<T>(args)...);
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2021-12-26 16:18:37 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static void LogVerbose(const AuString &line)
|
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLine(static_cast<AuUInt8>(ELogLevel::eVerbose), ConsoleMessage(EAnsiColor::eYellow, "Verbose", line));
|
2021-12-26 16:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(STAGING) || defined(DEBUG)
|
|
|
|
static void LogVerboseNoShip(const AuString &line)
|
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLine(static_cast<AuUInt8>(ELogLevel::eVerbose), ConsoleMessage(EAnsiColor::eYellow, "Verbose", line));
|
2021-12-26 16:18:37 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define LogVerboseNoShip(...) DoNothing()
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void DoNothing()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void LogInfo(const AuString &line)
|
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLine(static_cast<AuUInt8>(ELogLevel::eInfo), ConsoleMessage(EAnsiColor::eGreen, "Info", line));
|
2021-12-26 16:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void LogDbg(const AuString &line)
|
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLine(static_cast<AuUInt8>(ELogLevel::eDebug), ConsoleMessage(EAnsiColor::eYellow, "Debug", line));
|
2021-12-26 16:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void LogWarn(const AuString &line)
|
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLine(static_cast<AuUInt8>(ELogLevel::eWarn), ConsoleMessage(EAnsiColor::eRed, "Warn", line));
|
2021-12-26 16:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void LogError(const AuString &line)
|
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLine(static_cast<AuUInt8>(ELogLevel::eError), ConsoleMessage(EAnsiColor::eBoldRed, "Error", line));
|
2021-12-26 16:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void LogGame(const AuString &line)
|
|
|
|
{
|
2022-01-21 22:37:29 +00:00
|
|
|
WriteLine(static_cast<AuUInt8>(ELogLevel::eGame), ConsoleMessage(EAnsiColor::eBlue, "Game", line));
|
2021-12-26 16:18:37 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 10:58:08 +00:00
|
|
|
#endif
|
2021-12-24 15:44:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ADD_AU_GLOBAL_ALIAS(level)\
|
|
|
|
template<typename ... T> \
|
2021-12-26 16:18:37 +00:00
|
|
|
static void AuLog ## level(T&& ... args) \
|
2021-12-24 15:44:51 +00:00
|
|
|
{ \
|
2022-01-19 18:30:57 +00:00
|
|
|
Aurora::Console::Logging::Log ## level(AuForward<T>(args)...); \
|
2021-12-24 15:44:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|