HelloAurora/Tests/Common/console.hpp

54 lines
1.2 KiB
C++

/***
Copyright (c) 2020 Reece Wilson (a/k/a "Reece"). All rights reserved.
File: console.hpp
Date: 2020-6-9
Originator: Reece
Purpose:
***/
#pragma once
#include <string>
#include <fmt/format.h>
namespace Aurora::UnitTesting::Console
{
enum class AnsiColor
{
kRed,
kBoldRed,
kGreen,
kBoldGreen,
kYellow,
kBoldYellow,
kBlue,
kBoldBlue,
kMagenta,
kBoldMagenta,
kCyan,
kBoldCyan,
kReset,
kCount
};
void Init();
void WriteLine(const std::string &prefix, AnsiColor color, const std::string &msg);
template<typename... Args>
static void Log(fmt::format_string<Args...> msg, Args&& ... args)
{
WriteLine("Log", AnsiColor::kGreen, fmt::format(msg, args...));
}
template<typename... Args>
static void Warn(fmt::format_string<Args...> msg, Args&& ... args)
{
WriteLine("Warn", AnsiColor::kRed, fmt::format(msg, args...));
}
template<typename... Args>
static void Debug(fmt::format_string<Args...> msg, Args&& ... args)
{
WriteLine("Debug", AnsiColor::kYellow, fmt::format(msg, args...));
}
}