SpiecsEngine
 
Loading...
Searching...
No Matches
Log.h
Go to the documentation of this file.
1/**
2* @file Log.h
3* @brief The Log Class Definitions.
4* @author Spices.
5*/
6
7#pragma once
8
9#define GLM_ENABLE_EXPERIMENTAL
10#include <glm/gtx/string_cast.hpp>
11
12// This ignores all warnings raised inside External headers
13#pragma warning(push, 0)
14#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE // This Macro must be defined.
15#include <spdlog/spdlog.h>
16#include <spdlog/fmt/ostr.h>
17#pragma warning(pop)
18
19namespace Spices {
20
21 /**
22 * brief Log Class defines log behaves.
23 */
24 class Log
25 {
26 public:
27
28 static bool m_IsInitialized;
29
30 public:
31
32 /**
33 * @brief Init Log.
34 */
35 static void Init();
36
37 /**
38 * @brief Shutdown Log.
39 */
40 static void ShutDown();
41
42 /**
43 * @brief Get Engine Stage Logger.
44 * @return Returns Engine Stage Logger.
45 */
46 static std::shared_ptr<spdlog::logger>& GetCoreLogger() { return s_CoreLogger; }
47
48 /**
49 * @brief Get Game Stage Logger.
50 * @return Returns Game Stage Logger.
51 */
52 static std::shared_ptr<spdlog::logger>& GetClientLogger() { return s_ClientLogger; }
53
54 public:
55
56 /**
57 * @brief using format_string_t instanced of fmt::format_string<Args...>;
58 */
59 template <typename... Args>
61
62 /**
63 * @brief Post handle with log message.
64 * @param[in] fmt format string.
65 * @param[in] args any param.
66 */
67 template <typename... Args>
68 static void PostHandle(format_string_t<Args...> fmt, Args &&...args);
69
70 private:
71
72 /**
73 * @brief Engine Stage Logger.
74 */
76
77 /**
78 * @brief Game Stage Logger.
79 */
81 };
82
83 template<typename ...Args>
84 inline void Log::PostHandle(format_string_t<Args...> fmt, Args && ...args)
85 {
87 }
88}
89
90template<typename OStream, glm::length_t L, typename T, glm::qualifier Q>
91inline OStream& operator<<(OStream& os, const glm::vec<L, T, Q>& vector)
92{
93 return os << glm::to_string(vector);
94}
95
96template<typename OStream, glm::length_t C, glm::length_t R, typename T, glm::qualifier Q>
97inline OStream& operator<<(OStream& os, const glm::mat<C, R, T, Q>& matrix)
98{
99 return os << glm::to_string(matrix);
100}
101
102template<typename OStream, typename T, glm::qualifier Q>
103inline OStream& operator<<(OStream& os, glm::qua<T, Q> quaternion)
104{
105 return os << glm::to_string(quaternion);
106}
107
108#ifdef SPICES_DEBUG
109
110// Core log macros
111#define SPICES_CORE_TRACE(...) { if(Spices::Log::m_IsInitialized) { Spices::Log::GetCoreLogger()->trace (__VA_ARGS__); Spices::Log::PostHandle(__VA_ARGS__); } else { std::cout << __VA_ARGS__ << std::endl; } }
112#define SPICES_CORE_INFO(...) { if(Spices::Log::m_IsInitialized) { Spices::Log::GetCoreLogger()->info (__VA_ARGS__); Spices::Log::PostHandle(__VA_ARGS__); } else { std::cout << __VA_ARGS__ << std::endl; } }
113#define SPICES_CORE_WARN(...) { if(Spices::Log::m_IsInitialized) { Spices::Log::GetCoreLogger()->warn (__VA_ARGS__); Spices::Log::PostHandle(__VA_ARGS__); } else { std::cout << __VA_ARGS__ << std::endl; } }
114#define SPICES_CORE_ERROR(...) { if(Spices::Log::m_IsInitialized) { Spices::Log::GetCoreLogger()->error (__VA_ARGS__); Spices::Log::PostHandle(__VA_ARGS__); /*throw std::runtime_error(__VA_ARGS__)*/ } else { std::cout << __VA_ARGS__ << std::endl; } }
115#define SPICES_CORE_CRITICAL(...) { if(Spices::Log::m_IsInitialized) { Spices::Log::GetCoreLogger()->critical (__VA_ARGS__); Spices::Log::PostHandle(__VA_ARGS__); /*throw std::runtime_error(__VA_ARGS__)*/ } else { std::cout << __VA_ARGS__ << std::endl; } }
116
117// Client log macros
118#define SPICES_TRACE(...) { if(Spices::Log::m_IsInitialized) { Spices::Log::GetClientLogger()->trace (__VA_ARGS__); Spices::Log::PostHandle(__VA_ARGS__); } else { std::cout << __VA_ARGS__ << std::endl; } }
119#define SPICES_INFO(...) { if(Spices::Log::m_IsInitialized) { Spices::Log::GetClientLogger()->info (__VA_ARGS__); Spices::Log::PostHandle(__VA_ARGS__); } else { std::cout << __VA_ARGS__ << std::endl; } }
120#define SPICES_WARN(...) { if(Spices::Log::m_IsInitialized) { Spices::Log::GetClientLogger()->warn (__VA_ARGS__); Spices::Log::PostHandle(__VA_ARGS__); } else { std::cout << __VA_ARGS__ << std::endl; } }
121#define SPICES_ERROR(...) { if(Spices::Log::m_IsInitialized) { Spices::Log::GetClientLogger()->error (__VA_ARGS__); Spices::Log::PostHandle(__VA_ARGS__); /*throw std::runtime_error(__VA_ARGS__)*/ } else { std::cout << __VA_ARGS__ << std::endl; } }
122#define SPICES_CRITICAL(...) { if(Spices::Log::m_IsInitialized) { Spices::Log::GetClientLogger()->critical (__VA_ARGS__); Spices::Log::PostHandle(__VA_ARGS__); /*throw std::runtime_error(__VA_ARGS__)*/ } else { std::cout << __VA_ARGS__ << std::endl; } }
123
124#endif // SPICES_DEBUG
125
126#ifdef SPICES_RELEASE
127
128// Core log macros
129#define SPICES_CORE_TRACE(...)
130#define SPICES_CORE_INFO(...)
131#define SPICES_CORE_WARN(...)
132#define SPICES_CORE_ERROR(...)
133#define SPICES_CORE_CRITICAL(...)
134
135// Client log macros
136#define SPICES_TRACE(...)
137#define SPICES_INFO(...)
138#define SPICES_WARN(...)
139#define SPICES_ERROR(...)
140#define SPICES_CRITICAL(...)
141
142#endif // SPICES_RELEASE
int main()
Main Function.
Definition EntryPoint.h:15
#define PROCESS_INSTANCE_ENTRY
Macros of modify Process instance state.
#define PROCESS_INSTANCE_EXIT
#define SPICES_PROFILE_ZONE
Application()
Constructor Function.
static void Run()
Run Our World.
Application Class. Our Engine Start here.
Definition Application.h:20
static std::shared_ptr< spdlog::logger > s_ClientLogger
Game Stage Logger.
Definition Log.h:80
static bool m_IsInitialized
Definition Log.h:28
static std::shared_ptr< spdlog::logger > s_CoreLogger
Engine Stage Logger.
Definition Log.h:75
static void Init()
Init Log.
Definition Log.cpp:24
static std::shared_ptr< spdlog::logger > & GetCoreLogger()
Get Engine Stage Logger.
Definition Log.h:46
static std::shared_ptr< spdlog::logger > & GetClientLogger()
Get Game Stage Logger.
Definition Log.h:52
static void PostHandle(format_string_t< Args... > fmt, Args &&...args)
Post handle with log message.
Definition Log.h:84
static void ShutDown()
Shutdown Log.
Definition Log.cpp:82
float m_FrameTime
time step(s) during frames.
Definition TimeStep.h:85
std::chrono::steady_clock::time_point m_StartTime
Engine Start time.
Definition TimeStep.h:75
void Flush()
Refresh time in each engine loop.
Definition TimeStep.cpp:26
const float & ft() const
Get time step during frames.
Definition TimeStep.h:51
TimeStep(const TimeStep &)=delete
Copy Constructor Function.
const uint64_t & fs() const
Get frames count.
Definition TimeStep.h:63
TimeStep()
Constructor Function.
Definition TimeStep.cpp:12
virtual ~TimeStep()=default
Destructor Function.
std::chrono::steady_clock::time_point m_LastTime
Last frame time.
Definition TimeStep.h:80
float m_GameTime
time step(s) since Engine Start.
Definition TimeStep.h:90
uint64_t m_Frames
Frames since Engine Start.
Definition TimeStep.h:95
TimeStep & operator=(const TimeStep &)=delete
Copy Assignment Operation.
const float & gt() const
Get time step since Engine Start.
Definition TimeStep.h:57
This Class handles our engine time step during frames. Global Unique.
Definition TimeStep.h:22
static TracyGPUContext & Get()
Get this Single Instance.
static std::shared_ptr< TracyGPUContext > m_TracyGPUContext
This Single Instance.
virtual ~TracyGPUContext()=default
Destructor Function.
tracy::VkCtx * m_Context
Tracy Vulkan Context.
TracyGPUContext(VulkanState &state)
Constructor Function.
VulkanState & m_VulkanState
VulkanState.
tracy::VkCtx *& GetContext()
Get Context.
static void CreateInstance(VulkanState &state)
Create this Single Instance.
Wapper of Tracy GPU collect features.
World Class. This class defines the basic behaves of World. When we create an new world,...
Definition World.h:41
static const char * memoryPoolNames[3]
MemoryPool's name.
Definition Core.h:43
std::shared_ptr< World > CreateWorld()
extern WorldCreation definition in Game.
Definition EntryPoint.cpp:6
static constexpr char const * name
Define a named category tag type.
static constexpr char const * name
Define a custom domain tag type.
static constexpr char const * message
Define a registered string tag type.
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74