80 lines
2.7 KiB
C++
Executable File
80 lines
2.7 KiB
C++
Executable File
#pragma once
|
|
#include "Deer/Memory.h"
|
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
|
#include "spdlog/spdlog.h"
|
|
|
|
namespace spdlog {
|
|
class logger;
|
|
}
|
|
|
|
// Simple file to define logs functions optimized depending on the compilation
|
|
|
|
namespace Deer {
|
|
class Log {
|
|
public:
|
|
static void init();
|
|
static void shutdown();
|
|
|
|
static void coreTrace(const char* msg);
|
|
|
|
static inline Ref<spdlog::logger>& getCoreLogger() {
|
|
return coreLogger;
|
|
}
|
|
static inline Ref<spdlog::logger>& getClientLogger() {
|
|
return clientLogger;
|
|
}
|
|
static inline Ref<spdlog::logger>& getScriptLogger() {
|
|
return scriptLogger;
|
|
}
|
|
static inline Ref<spdlog::logger>& getUiEngineLogger() {
|
|
return uiEngineLogger;
|
|
}
|
|
|
|
private:
|
|
static Ref<spdlog::logger> coreLogger;
|
|
static Ref<spdlog::logger> clientLogger;
|
|
static Ref<spdlog::logger> scriptLogger;
|
|
static Ref<spdlog::logger> uiEngineLogger;
|
|
};
|
|
} // namespace Deer
|
|
|
|
#define DEER_CORE_TRACE(...) Deer::Log::getCoreLogger()->trace(__VA_ARGS__)
|
|
#define DEER_CORE_INFO(...) Deer::Log::getCoreLogger()->info(__VA_ARGS__)
|
|
#define DEER_CORE_WARN(...) Deer::Log::getCoreLogger()->warn(__VA_ARGS__)
|
|
#define DEER_CORE_ERROR(...) Deer::Log::getCoreLogger()->error(__VA_ARGS__)
|
|
|
|
#define DEER_SCRIPT_TRACE(...) Deer::Log::getScriptLogger()->trace(__VA_ARGS__)
|
|
#define DEER_SCRIPT_INFO(...) Deer::Log::getScriptLogger()->info(__VA_ARGS__)
|
|
#define DEER_SCRIPT_WARN(...) Deer::Log::getScriptLogger()->warn(__VA_ARGS__)
|
|
#define DEER_SCRIPT_ERROR(...) Deer::Log::getScriptLogger()->error(__VA_ARGS__)
|
|
|
|
|
|
#define DEER_UI_ENGINE_TRACE(...) Deer::Log::getUiEngineLogger()->trace(__VA_ARGS__)
|
|
#define DEER_UI_ENGINE_INFO(...) Deer::Log::getUiEngineLogger()->info(__VA_ARGS__)
|
|
#define DEER_UI_ENGINE_WARN(...) Deer::Log::getUiEngineLogger()->warn(__VA_ARGS__)
|
|
#define DEER_UI_ENGINE_ERROR(...) Deer::Log::getUiEngineLogger()->error(__VA_ARGS__)
|
|
|
|
#ifdef LINUX
|
|
#define DEER_CORE_ASSERT(condition, ...) \
|
|
if (!(condition)) { \
|
|
Deer::Log::getCoreLogger()->error(__VA_ARGS__); \
|
|
__builtin_trap(); \
|
|
}
|
|
#define DEER_SCRIPT_ASSERT(condition, ...) \
|
|
if (!(condition)) { \
|
|
Deer::Log::getScriptLogger()->error(__VA_ARGS__); \
|
|
}
|
|
#endif
|
|
#ifdef WINDOWS
|
|
#define DEER_CORE_ASSERT(condition, ...) \
|
|
if (!(condition)) { \
|
|
Deer::Log::getCoreLogger()->error(__VA_ARGS__); \
|
|
__debugbreak(); \
|
|
}
|
|
#define DEER_SCRIPT_ASSERT(condition, ...) \
|
|
if (!(condition)) { \
|
|
Deer::Log::getScriptLogger()->error(__VA_ARGS__); \
|
|
__debugbreak(); \
|
|
}
|
|
#endif
|