Added functions that wrap around logging macros for C++/CLI integration
This commit is contained in:
parent
5f56344a74
commit
e45e589ba9
|
@ -6,6 +6,8 @@
|
|||
#include "Scenes/SBEditorScene.h"
|
||||
#endif // SHEDITOR
|
||||
|
||||
#include "Tools/SHLogger.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <ratio>
|
||||
#include <ctime>
|
||||
|
@ -21,6 +23,7 @@ namespace Sandbox
|
|||
_In_ INT nCmdShow
|
||||
)
|
||||
{
|
||||
SHLOG_TITLE("Initialising SBApplication")
|
||||
|
||||
window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||
|
||||
|
|
|
@ -34,8 +34,6 @@ INT WINAPI wWinMain
|
|||
//ShowWindow(::GetConsoleWindow(), SW_HIDE);
|
||||
#endif
|
||||
|
||||
SHLOG_INFO("sup")
|
||||
|
||||
SHADE::SHEngine::Run<Sandbox::SBApplication>(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
}
|
||||
|
|
|
@ -174,6 +174,7 @@
|
|||
<ClInclude Include="src\Graphics\Windowing\Surface\SHVkSurface.h" />
|
||||
<ClInclude Include="src\Math\SHMath.h" />
|
||||
<ClInclude Include="src\Math\SHMathHelpers.h" />
|
||||
<ClInclude Include="src\Math\SHMathHelpers.hpp" />
|
||||
<ClInclude Include="src\Math\SHMatrix.h" />
|
||||
<ClInclude Include="src\Math\SHQuaternion.h" />
|
||||
<ClInclude Include="src\Math\Vector\SHVec2.h" />
|
||||
|
|
|
@ -382,6 +382,7 @@
|
|||
<ClInclude Include="src\Tools\SHUtilities.h">
|
||||
<Filter>Tools</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Math\SHMathHelpers.hpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\ECS_Base\Components\SHComponent.cpp">
|
||||
|
|
|
@ -211,6 +211,143 @@ namespace SHADE
|
|||
sinks[1]->set_pattern(verbosePattern + "%v"); // File Sink
|
||||
}
|
||||
|
||||
void SHLogger::LogInfo(const std::string& msg) noexcept
|
||||
{
|
||||
SHLOG_INFO(msg)
|
||||
}
|
||||
|
||||
void SHLogger::LogVerboseInfo(const std::string& msg, const std::source_location& src) noexcept
|
||||
{
|
||||
const bool SHOW_SRC_FILE = configFlags & (1U << 3);
|
||||
const bool SHOW_SRC_LINE = configFlags & (1U << 4);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "[";
|
||||
if (SHOW_SRC_FILE)
|
||||
{
|
||||
ss << std::filesystem::path(src.file_name()).filename().string() << ", ";
|
||||
if (SHOW_SRC_LINE)
|
||||
{
|
||||
ss << src.line() << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
ss << src.function_name() << "] " << msg;
|
||||
|
||||
SHLOG_INFO(ss.str())
|
||||
}
|
||||
|
||||
void SHLogger::LogWarning(const std::string& msg) noexcept
|
||||
{
|
||||
SHLOG_WARNING(msg)
|
||||
}
|
||||
|
||||
void SHLogger::LogVerboseWarning(const std::string& msg, const std::source_location& src) noexcept
|
||||
{
|
||||
const bool SHOW_SRC_FILE = configFlags & (1U << 3);
|
||||
const bool SHOW_SRC_LINE = configFlags & (1U << 4);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "[";
|
||||
if (SHOW_SRC_FILE)
|
||||
{
|
||||
ss << std::filesystem::path(src.file_name()).filename().string() << ", ";
|
||||
if (SHOW_SRC_LINE)
|
||||
{
|
||||
ss << src.line() << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
ss << src.function_name() << "] " << msg;
|
||||
|
||||
SHLOG_WARNING(ss.str())
|
||||
}
|
||||
|
||||
void SHLogger::LogError(const std::string& msg) noexcept
|
||||
{
|
||||
SHLOG_ERROR(msg)
|
||||
}
|
||||
|
||||
void SHLogger::LogVerboseError(const std::string& msg, const std::source_location& src) noexcept
|
||||
{
|
||||
const bool SHOW_SRC_FILE = configFlags & (1U << 3);
|
||||
const bool SHOW_SRC_LINE = configFlags & (1U << 4);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "[";
|
||||
if (SHOW_SRC_FILE)
|
||||
{
|
||||
ss << std::filesystem::path(src.file_name()).filename().string() << ", ";
|
||||
if (SHOW_SRC_LINE)
|
||||
{
|
||||
ss << src.line() << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
ss << src.function_name() << "] " << msg;
|
||||
|
||||
SHLOG_ERROR(ss.str())
|
||||
}
|
||||
|
||||
void SHLogger::LogCritical(const std::string& msg) noexcept
|
||||
{
|
||||
SHLOG_CRITICAL(msg)
|
||||
}
|
||||
|
||||
void SHLogger::LogVerboseCritical(const std::string& msg, const std::source_location& src) noexcept
|
||||
{
|
||||
const bool SHOW_SRC_FILE = configFlags & (1U << 3);
|
||||
const bool SHOW_SRC_LINE = configFlags & (1U << 4);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "[";
|
||||
if (SHOW_SRC_FILE)
|
||||
{
|
||||
ss << std::filesystem::path(src.file_name()).filename().string() << ", ";
|
||||
if (SHOW_SRC_LINE)
|
||||
{
|
||||
ss << src.line() << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
ss << src.function_name() << "] " << msg;
|
||||
|
||||
SHLOG_CRITICAL(ss.str())
|
||||
}
|
||||
|
||||
void SHLogger::LogFloor() noexcept
|
||||
{
|
||||
SHLOG_FLOOR()
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
void SHLogger::LogTrace(const std::string& msg) noexcept
|
||||
{
|
||||
SHLOG_TRACE(msg)
|
||||
}
|
||||
|
||||
void SHLogger::LogVerboseTrace(const std::string& msg, const std::source_location& src) noexcept
|
||||
{
|
||||
const bool SHOW_SRC_FILE = configFlags & (1U << 3);
|
||||
const bool SHOW_SRC_LINE = configFlags & (1U << 4);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "[";
|
||||
if (SHOW_SRC_FILE)
|
||||
{
|
||||
ss << std::filesystem::path(src.file_name()).filename().string() << ", ";
|
||||
if (SHOW_SRC_LINE)
|
||||
{
|
||||
ss << src.line() << ", ";
|
||||
}
|
||||
}
|
||||
|
||||
ss << src.function_name() << "] " << msg;
|
||||
|
||||
SHLOG_TRACE(ss.str())
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Private Function Member Definitions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <string_view>
|
||||
#include <filesystem>
|
||||
#include <source_location>
|
||||
|
||||
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
|
||||
#include <spdlog/spdlog.h>
|
||||
|
@ -118,6 +119,23 @@ namespace SHADE
|
|||
*/
|
||||
static void UseVerbosePattern () noexcept;
|
||||
|
||||
/// Logging Functions to interface with C++/CLI.
|
||||
|
||||
static void LogInfo (const std::string& msg) noexcept;
|
||||
static void LogVerboseInfo (const std::string& msg, const std::source_location& src= std::source_location::current()) noexcept;
|
||||
static void LogWarning (const std::string& msg) noexcept;
|
||||
static void LogVerboseWarning (const std::string& msg, const std::source_location& src = std::source_location::current()) noexcept;
|
||||
static void LogError (const std::string& msg) noexcept;
|
||||
static void LogVerboseError (const std::string& msg, const std::source_location& src = std::source_location::current()) noexcept;
|
||||
static void LogCritical (const std::string& msg) noexcept;
|
||||
static void LogVerboseCritical (const std::string& msg, const std::source_location& src = std::source_location::current()) noexcept;
|
||||
static void LogFloor () noexcept;
|
||||
|
||||
#ifdef _DEBUG
|
||||
static void LogTrace (const std::string& msg) noexcept;
|
||||
static void LogVerboseTrace (const std::string& msg, const std::source_location& src = std::source_location::current()) noexcept;
|
||||
#endif
|
||||
|
||||
private:
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Data Members */
|
||||
|
|
Loading…
Reference in New Issue