Added logging to the engine
This commit is contained in:
parent
5e77883bd2
commit
531cfbd006
6 changed files with 70 additions and 3 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "FluxEngine/vendor/spdlog"]
|
||||
path = FluxEngine/vendor/spdlog
|
||||
url = https://github.com/gabime/spdlog
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "Flux/Application.h"
|
||||
#include "Flux/Log.h"
|
||||
|
||||
#include "Flux/EntryPoint.h"
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include "../Flux.h"
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
#ifdef FLUX_PLATFORM_WINDOWS
|
||||
|
||||
|
@ -7,6 +8,12 @@ extern Flux::Application* Flux::CreateApplication();
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
Flux::Log::Init();
|
||||
|
||||
FLUX_CORE_WARN("Logging Initialized!");
|
||||
int a = 5;
|
||||
FLUX_INFO("Hello! {0}", a);
|
||||
|
||||
auto app = Flux::CreateApplication();
|
||||
app->Run();
|
||||
delete app;
|
||||
|
|
19
FluxEngine/src/Flux/Log.cpp
Normal file
19
FluxEngine/src/Flux/Log.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include "Log.h"
|
||||
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
|
||||
namespace Flux
|
||||
{
|
||||
std::shared_ptr<spdlog::logger> Log::s_CoreLogger;
|
||||
std::shared_ptr<spdlog::logger> Log::s_ClientLogger;
|
||||
|
||||
void Log::Init()
|
||||
{
|
||||
spdlog::set_pattern("%^[%T] %n: %v%$");
|
||||
s_CoreLogger = spdlog::stdout_color_mt("FLUX");
|
||||
s_CoreLogger->set_level(spdlog::level::trace);
|
||||
|
||||
s_ClientLogger = spdlog::stdout_color_mt("APP");
|
||||
s_ClientLogger->set_level(spdlog::level::trace);
|
||||
}
|
||||
}
|
36
FluxEngine/src/Flux/Log.h
Normal file
36
FluxEngine/src/Flux/Log.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
#include "Core.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
namespace Flux
|
||||
{
|
||||
class FLUX_API Log
|
||||
{
|
||||
public:
|
||||
static void Init();
|
||||
inline static std::shared_ptr<spdlog::logger>& GetCoreLogger() { return s_CoreLogger; }
|
||||
inline static std::shared_ptr<spdlog::logger>& GetClientLogger() { return s_ClientLogger; }
|
||||
private:
|
||||
static std::shared_ptr<spdlog::logger> s_CoreLogger;
|
||||
static std::shared_ptr<spdlog::logger> s_ClientLogger;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Core log macros
|
||||
#define FLUX_CORE_TRACE(...) ::Flux::Log::GetCoreLogger()->trace(__VA_ARGS__)
|
||||
#define FLUX_CORE_INFO(...) ::Flux::Log::GetCoreLogger()->info(__VA_ARGS__)
|
||||
#define FLUX_CORE_WARN(...) ::Flux::Log::GetCoreLogger()->warn(__VA_ARGS__)
|
||||
#define FLUX_CORE_ERROR(...) ::Flux::Log::GetCoreLogger()->error(__VA_ARGS__)
|
||||
#define FLUX_CORE_FATAL(...) ::Flux::Log::GetCoreLogger()->fatal(__VA_ARGS__)
|
||||
|
||||
// Client log macros
|
||||
#define FLUX_TRACE(...) ::Flux::Log::GetCoreLogger()->trace(__VA_ARGS__)
|
||||
#define FLUX_INFO(...) ::Flux::Log::GetCoreLogger()->info(__VA_ARGS__)
|
||||
#define FLUX_WARN(...) ::Flux::Log::GetCoreLogger()->warn(__VA_ARGS__)
|
||||
#define FLUX_ERROR(...) ::Flux::Log::GetCoreLogger()->error(__VA_ARGS__)
|
||||
#define FLUX_FATAL(...) ::Flux::Log::GetCoreLogger()->fatal(__VA_ARGS__)
|
|
@ -22,7 +22,7 @@ project "FluxEngine"
|
|||
|
||||
includedirs
|
||||
{
|
||||
|
||||
"%{prj.name}/vendor/spdlog/include",
|
||||
}
|
||||
|
||||
filter "system:windows"
|
||||
|
@ -67,7 +67,8 @@ project "Sandbox"
|
|||
|
||||
includedirs
|
||||
{
|
||||
"Flux/src"
|
||||
"FluxEngine/vendor/spdlog/include",
|
||||
"FluxEngine/src"
|
||||
}
|
||||
|
||||
links
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue