Added spdlog
This commit is contained in:
parent
8ee8377c25
commit
ce790b4d38
12 changed files with 112 additions and 7 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "Dependencies/spdlog"]
|
||||||
|
path = Dependencies/spdlog
|
||||||
|
url = https://github.com/gabime/spdlog
|
|
@ -12,6 +12,7 @@ workspace "Light"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Directories --
|
-- Directories --
|
||||||
|
dependenciesdir = "%{wks.location}/Dependencies/"
|
||||||
outputdir = "%{cfg.buildcfg}/%{cfg.system}/%{cfg.architecture}/%{prj.name}"
|
outputdir = "%{cfg.buildcfg}/%{cfg.system}/%{cfg.architecture}/%{prj.name}"
|
||||||
|
|
||||||
-- Projects --
|
-- Projects --
|
||||||
|
|
2
BuildScripts/vs2019.bat
Normal file
2
BuildScripts/vs2019.bat
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
premake5.exe vs2019
|
||||||
|
PAUSE
|
1
Dependencies/spdlog
vendored
Submodule
1
Dependencies/spdlog
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 6ba5ab6d6709cc277a9486b08203cb4c4f876aca
|
|
@ -15,13 +15,18 @@ project "Engine"
|
||||||
-- Project Files ---
|
-- Project Files ---
|
||||||
files
|
files
|
||||||
{
|
{
|
||||||
"%{prj.location}/**.h",
|
"%{prj.location}/src/**.h",
|
||||||
"%{prj.location}/**.cpp",
|
"%{prj.location}/src/**.cpp",
|
||||||
"%{prj.location}/**.lua",
|
"%{prj.location}/**.lua",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Dependencies --
|
-- Dependencies --
|
||||||
-- NILL --
|
includedirs
|
||||||
|
{
|
||||||
|
"%{prj.location}/src/Engine/",
|
||||||
|
|
||||||
|
(dependenciesdir .. "spdlog/include/"),
|
||||||
|
}
|
||||||
|
|
||||||
--- Filters ---
|
--- Filters ---
|
||||||
-- windows
|
-- windows
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
namespace Light {
|
namespace Light {
|
||||||
|
|
||||||
Application::Application()
|
Application::Application()
|
||||||
{
|
{
|
||||||
|
Logger::Initialize();
|
||||||
|
|
||||||
|
LT_ENGINE_INFO("Initialized Logger");
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application()
|
Application::~Application()
|
23
Engine/src/Engine/Core/Logger.cpp
Normal file
23
Engine/src/Engine/Core/Logger.cpp
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
50
Engine/src/Engine/Core/Logger.h
Normal file
50
Engine/src/Engine/Core/Logger.h
Normal 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; }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Engine/Core/Application.h"
|
||||||
|
#include "Engine/Core/Logger.h"
|
||||||
|
|
||||||
#include "Engine/Base.h"
|
#include "Engine/Base.h"
|
||||||
|
|
||||||
#include "Engine/Application.h"
|
|
||||||
|
|
||||||
#include "Engine/EntryPoint.h"
|
#include "Engine/EntryPoint.h"
|
|
@ -23,7 +23,12 @@ project "Sandbox"
|
||||||
-- Dependencies --
|
-- Dependencies --
|
||||||
includedirs
|
includedirs
|
||||||
{
|
{
|
||||||
|
-- Engine
|
||||||
"%{wks.location}/Engine/src",
|
"%{wks.location}/Engine/src",
|
||||||
|
"%{wks.location}/Engine/src/Engine",
|
||||||
|
|
||||||
|
-- 3rd party
|
||||||
|
(dependenciesdir .. "spdlog/include/"),
|
||||||
}
|
}
|
||||||
|
|
||||||
links
|
links
|
||||||
|
|
|
@ -2,6 +2,16 @@
|
||||||
|
|
||||||
class Sandbox : public Light::Application
|
class Sandbox : public Light::Application
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
Sandbox()
|
||||||
|
{
|
||||||
|
LT_CLIENT_TRACE("Sandbox::Sandbox");
|
||||||
|
}
|
||||||
|
|
||||||
|
~Sandbox()
|
||||||
|
{
|
||||||
|
LT_CLIENT_TRACE("Sandbox::~Sandbox");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Light::Application* Light::CreateApplication()
|
Light::Application* Light::CreateApplication()
|
||||||
|
|
Loading…
Add table
Reference in a new issue