Added spdlog

This commit is contained in:
Light3039 2021-05-21 10:55:39 +04:30
parent 8ee8377c25
commit ce790b4d38
12 changed files with 112 additions and 7 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "Dependencies/spdlog"]
path = Dependencies/spdlog
url = https://github.com/gabime/spdlog

View file

@ -12,6 +12,7 @@ workspace "Light"
}
-- Directories --
dependenciesdir = "%{wks.location}/Dependencies/"
outputdir = "%{cfg.buildcfg}/%{cfg.system}/%{cfg.architecture}/%{prj.name}"
-- Projects --

2
BuildScripts/vs2019.bat Normal file
View file

@ -0,0 +1,2 @@
premake5.exe vs2019
PAUSE

1
Dependencies/spdlog vendored Submodule

@ -0,0 +1 @@
Subproject commit 6ba5ab6d6709cc277a9486b08203cb4c4f876aca

View file

@ -15,13 +15,18 @@ project "Engine"
-- Project Files ---
files
{
"%{prj.location}/**.h",
"%{prj.location}/**.cpp",
"%{prj.location}/src/**.h",
"%{prj.location}/src/**.cpp",
"%{prj.location}/**.lua",
}
-- Dependencies --
-- NILL --
includedirs
{
"%{prj.location}/src/Engine/",
(dependenciesdir .. "spdlog/include/"),
}
--- Filters ---
-- windows

View file

@ -1,9 +1,14 @@
#include "Application.h"
#include "Logger.h"
namespace Light {
Application::Application()
{
Logger::Initialize();
LT_ENGINE_INFO("Initialized Logger");
}
Application::~Application()

View file

@ -0,0 +1,23 @@
#include "Logger.h"
#include <spdlog/sinks/stdout_color_sinks.h>
namespace Light {
std::shared_ptr<spdlog::logger> Logger::s_EngineLogger;
std::shared_ptr<spdlog::logger> Logger::s_ClientLogger;
void Light::Logger::Initialize()
{
// Set spdlog pattern
spdlog::set_pattern("%^[%M:%S:%e] <%n>: %v%$");
// Create loggers and set levels to minimum
s_EngineLogger = spdlog::stdout_color_mt("Engine");
s_EngineLogger->set_level(spdlog::level::trace);
s_ClientLogger = spdlog::stdout_color_mt("Client");
s_ClientLogger->set_level(spdlog::level::trace);
}
}

View file

@ -0,0 +1,50 @@
#pragma once
// TODO: File logger
//
#include "Base.h"
#include <spdlog/spdlog.h>
// LOGGER MACROS //
#ifndef LT_DIST
// Engine
#define LT_ENGINE_TRACE(...) ::Light::Logger::GetEngineLogger()->log(spdlog::level::trace , __VA_ARGS__)
#define LT_ENGINE_INFO(...) ::Light::Logger::GetEngineLogger()->log(spdlog::level::info , __VA_ARGS__)
#define LT_ENGINE_WARN(...) ::Light::Logger::GetEngineLogger()->log(spdlog::level::warn , __VA_ARGS__)
#define LT_ENGINE_ERROR(...) ::Light::Logger::GetEngineLogger()->log(spdlog::level::err , __VA_ARGS__)
#define LT_ENGINE_CRITICAL(...) ::Light::Logger::GetEngineLogger()->log(spdlog::level::critical, __VA_ARGS__)
// Client
#define LT_CLIENT_TRACE(...) ::Light::Logger::GetClientLogger()->log(spdlog::level::trace , __VA_ARGS__)
#define LT_CLIENT_INFO(...) ::Light::Logger::GetClientLogger()->log(spdlog::level::info , __VA_ARGS__)
#define LT_CLIENT_WARN(...) ::Light::Logger::GetClientLogger()->log(spdlog::level::warn , __VA_ARGS__)
#define LT_CLIENT_ERROR(...) ::Light::Logger::GetClientLogger()->log(spdlog::level::err , __VA_ARGS__)
#define LT_CLIENT_CRITICAL(...) ::Light::Logger::GetClientLogger()->log(spdlog::level::critical, __VA_ARGS__)
#else
#define LT_ENGINE_TRACE(...)
#define LT_ENGINE_INFO(...)
#define LT_ENGINE_WARN(...)
#define LT_ENGINE_ERROR(...)
#define LT_ENGINE_CRITICAL(...)
#define LT_CLIENT_TRACE(...)
#define LT_CLIENT_INFO(...)
#define LT_CLIENT_WARN(...)
#define LT_CLIENT_ERROR(...)
#define LT_CLIENT_CRITICAL(...)
#endif
namespace Light {
class Logger
{
private:
static std::shared_ptr<spdlog::logger> s_EngineLogger, s_ClientLogger;
public:
static void Initialize();
static inline std::shared_ptr<spdlog::logger> GetEngineLogger() { return s_EngineLogger; }
static inline std::shared_ptr<spdlog::logger> GetClientLogger() { return s_ClientLogger; }
};
}

View file

@ -1,7 +1,7 @@
#pragma once
#include "Engine/Core/Application.h"
#include "Engine/Core/Logger.h"
#include "Engine/Base.h"
#include "Engine/Application.h"
#include "Engine/EntryPoint.h"

View file

@ -3,7 +3,7 @@ project "Sandbox"
-- Output Directories --
location "../Sandbox/"
targetdir ("../bin/" .. outputdir)
targetdir ("../bin/" .. outputdir)
objdir ("../bin-int/" .. outputdir)
-- Compiler --
@ -23,7 +23,12 @@ project "Sandbox"
-- Dependencies --
includedirs
{
-- Engine
"%{wks.location}/Engine/src",
"%{wks.location}/Engine/src/Engine",
-- 3rd party
(dependenciesdir .. "spdlog/include/"),
}
links

View file

@ -2,6 +2,16 @@
class Sandbox : public Light::Application
{
public:
Sandbox()
{
LT_CLIENT_TRACE("Sandbox::Sandbox");
}
~Sandbox()
{
LT_CLIENT_TRACE("Sandbox::~Sandbox");
}
};
Light::Application* Light::CreateApplication()