Updated logging
This commit is contained in:
21
Common/IO.h
21
Common/IO.h
@@ -18,7 +18,7 @@ namespace LXC::Util
|
||||
template<typename... Args> concept AllLogable = (Logable<Args> && ...);
|
||||
|
||||
// Enum to translate to the Win32 code for the colors //
|
||||
enum class Color : WORD
|
||||
enum Color : WORD
|
||||
{
|
||||
BLACK = 0x00,
|
||||
BLUE = 0x01,
|
||||
@@ -50,4 +50,23 @@ namespace LXC::Util
|
||||
(std::cout << ... << args);
|
||||
SetConsoleTextAttribute(hConsole, (WORD)Color::LIGHT_GRAY);
|
||||
}
|
||||
|
||||
// Prints arguments to the console //
|
||||
template<typename... Args>
|
||||
requires AllLogable<Args...>
|
||||
inline void Print(Args... args)
|
||||
{
|
||||
// Fowards the arguments to the console //
|
||||
(std::cout << ... << args);
|
||||
}
|
||||
|
||||
// Prints arguments to the console with a new-line character at the end //
|
||||
template<typename... Args>
|
||||
requires AllLogable<Args...>
|
||||
inline void PrintLn(Args... args)
|
||||
{
|
||||
// Fowards the arguments to the console //
|
||||
(std::cout << ... << args);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,22 @@
|
||||
|
||||
namespace LXC::Util
|
||||
{
|
||||
// Util function to stop/ the program //
|
||||
inline void Stop()
|
||||
{
|
||||
// Only checks for a debugger when compiled in Debug mode //
|
||||
#ifdef _DEBUG
|
||||
|
||||
// Triggers a breakpoint so the debugger can work out where the program exits //
|
||||
if (IsDebuggerPresent())
|
||||
DebugBreak();
|
||||
|
||||
#endif // _DEBUG
|
||||
|
||||
// Force exits the program //
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Custom version of std::unexpected //
|
||||
template<typename ErrorType> struct FunctionFail
|
||||
{
|
||||
@@ -20,7 +36,7 @@ namespace LXC::Util
|
||||
if (IsDebuggerPresent())
|
||||
DebugBreak();
|
||||
|
||||
#endif
|
||||
#endif // _DEBUG
|
||||
}
|
||||
|
||||
ErrorType error;
|
||||
|
||||
Reference in New Issue
Block a user