Added SHLog class and changed Debug::Log to use SHLog
This commit is contained in:
parent
c83a5a379e
commit
5171ddd2bf
|
@ -0,0 +1,54 @@
|
|||
/************************************************************************************//*!
|
||||
\file SHLog.cpp
|
||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||
\par email: kahwei.tng\@digipen.edu
|
||||
\date Sep 17, 2022
|
||||
\brief Contains the definition of functions of the SHLog static class.
|
||||
|
||||
Copyright (C) 2022 DigiPen Institute of Technology.
|
||||
Reproduction or disclosure of this file or its contents without the prior written consent
|
||||
of DigiPen Institute of Technology is prohibited.
|
||||
*//*************************************************************************************/
|
||||
// Precompiled Header
|
||||
#include "SHpch.h"
|
||||
// Primary Header
|
||||
#include "SHLog.h"
|
||||
// Project Includes
|
||||
#include "SHLogger.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
void SHLog::Info(const std::string& msg) noexcept
|
||||
{
|
||||
SHLOG_INFO(msg)
|
||||
}
|
||||
|
||||
void SHLog::Warning(const std::string& msg) noexcept
|
||||
{
|
||||
SHLOG_WARNING(msg)
|
||||
}
|
||||
|
||||
|
||||
void SHLog::Error(const std::string& msg) noexcept
|
||||
{
|
||||
SHLOG_ERROR(msg)
|
||||
}
|
||||
|
||||
void SHLog::Critical(const std::string& msg) noexcept
|
||||
{
|
||||
SHLOG_CRITICAL(msg)
|
||||
}
|
||||
|
||||
void SHLog::Floor() noexcept
|
||||
{
|
||||
SHLOG_FLOOR()
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
void SHLog::Trace(const std::string& msg) noexcept
|
||||
{
|
||||
SHLOG_TRACE(msg)
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/************************************************************************************//*!
|
||||
\file SHLog.h
|
||||
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||
\par email: kahwei.tng\@digipen.edu
|
||||
\date Sep 17, 2022
|
||||
\brief Contains the SHLog static class.
|
||||
|
||||
Copyright (C) 2022 DigiPen Institute of Technology.
|
||||
Reproduction or disclosure of this file or its contents without the prior written consent
|
||||
of DigiPen Institute of Technology is prohibited.
|
||||
*//*************************************************************************************/
|
||||
|
||||
// Standard Library
|
||||
#include <string>
|
||||
// Project Headers
|
||||
#include "SH_API.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
/*!************************************************************************************
|
||||
|
||||
\class SHLog
|
||||
|
||||
\brief
|
||||
Static class that contains wrapper functions for SHLogger's macros.
|
||||
|
||||
**************************************************************************************/
|
||||
class SH_API SHLog
|
||||
{
|
||||
public:
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Constructor */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
SHLog() = delete;
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Logging Functions */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
static void Info(const std::string& msg) noexcept;
|
||||
static void Warning(const std::string& msg) noexcept;
|
||||
static void Error(const std::string& msg) noexcept;
|
||||
static void Critical(const std::string& msg) noexcept;
|
||||
static void Floor() noexcept;
|
||||
#ifdef _DEBUG
|
||||
static void Trace(const std::string& msg) noexcept;
|
||||
#endif
|
||||
};
|
||||
}
|
|
@ -18,6 +18,8 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include "Debug.hxx"
|
||||
// Standard Libraries
|
||||
#include <sstream>
|
||||
// External Libraries
|
||||
#include "Tools/SHLog.h"
|
||||
// Project Headers
|
||||
#include "Convert.hxx"
|
||||
|
||||
|
@ -28,11 +30,11 @@ namespace SHADE
|
|||
/*---------------------------------------------------------------------------------*/
|
||||
void Debug::Log(const std::string& str)
|
||||
{
|
||||
std::cout << str << std::endl;
|
||||
SHLog::Info(str);
|
||||
}
|
||||
void Debug::Log(System::String^ str)
|
||||
{
|
||||
System::Console::WriteLine(str);
|
||||
{
|
||||
SHLog::Info(Convert::ToNative(str));
|
||||
}
|
||||
|
||||
void Debug::Log(System::String^ str, Object^ owner)
|
||||
|
@ -47,15 +49,15 @@ namespace SHADE
|
|||
{
|
||||
std::ostringstream oss;
|
||||
oss << "[" << throwerName << "] " << Convert::ToNative(str);
|
||||
std::cout << oss.str() << std::endl;
|
||||
Log(oss.str());
|
||||
}
|
||||
void Debug::LogWarning(const std::string& str)
|
||||
{
|
||||
std::cout << str << std::endl;
|
||||
SHLog::Warning(str);
|
||||
}
|
||||
void Debug::LogWarning(System::String^ str)
|
||||
{
|
||||
System::Console::WriteLine(str);
|
||||
{
|
||||
SHLog::Warning(Convert::ToNative(str));
|
||||
}
|
||||
void Debug::LogWarning(System::String^ str, Object^ thrower)
|
||||
{
|
||||
|
@ -69,16 +71,16 @@ namespace SHADE
|
|||
void Debug::LogWarning(System::String^ str, const std::string& throwerName)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "[" << throwerName << "] " << Convert::ToNative(str);
|
||||
std::cout << oss.str() << std::endl;
|
||||
oss << "[" << throwerName << "] " << Convert::ToNative(str);
|
||||
LogWarning(oss.str());
|
||||
}
|
||||
void Debug::LogError(const std::string& str)
|
||||
{
|
||||
std::cout << str << std::endl;
|
||||
SHLog::Error(str);
|
||||
}
|
||||
void Debug::LogError(System::String^ str)
|
||||
{
|
||||
System::Console::WriteLine(str);
|
||||
SHLog::Error(Convert::ToNative(str));
|
||||
}
|
||||
void Debug::LogError(System::String^ str, Object^ thrower)
|
||||
{
|
||||
|
@ -88,7 +90,7 @@ namespace SHADE
|
|||
{
|
||||
std::ostringstream oss;
|
||||
oss << "[" << throwerName << "] -> " << Convert::ToNative(str);
|
||||
std::cout << oss.str() << std::endl;
|
||||
LogError(oss.str());
|
||||
}
|
||||
void Debug::LogError(System::String^ str, System::String^ throwerName)
|
||||
{
|
||||
|
@ -111,12 +113,12 @@ namespace SHADE
|
|||
{
|
||||
std::ostringstream oss;
|
||||
oss << "[" << throwerName << "] Unhandled exception: " << Convert::ToNative(exception->ToString());
|
||||
std::cout << oss.str() << std::endl;
|
||||
LogError(oss.str());
|
||||
}
|
||||
void Debug::LogExceptionNative(const std::exception& exception, const std::string& throwerName)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "[" << throwerName << "] Unhandled exception: " << exception.what();
|
||||
std::cout << oss.str() << std::endl;
|
||||
LogError(oss.str());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue