light/modules/engine/include/engine/debug/logger.hpp

57 lines
1.1 KiB
C++
Raw Normal View History

2025-07-05 13:28:41 +03:30
#pragma once
#ifndef LIGHT_LOGGER_H
#define LIGHT_LOGGER_H
#include <engine/base/base.hpp>
#include <spdlog/spdlog.h>
#define LT_LOG_FILE_LOCATION "Logs/logger.txt"
2025-07-05 13:28:41 +03:30
#ifndef LIGHT_DIST
2025-07-05 16:07:51 +03:30
#define lt_log(logLevel, ...) \
SPDLOG_LOGGER_CALL( \
::Light::logger::get_engine_logger(), \
2025-07-05 16:07:51 +03:30
spdlog::level::logLevel, \
__VA_ARGS__ \
2025-07-05 13:28:41 +03:30
)
#else
2025-07-05 16:07:51 +03:30
#define lt_log(logLevel, ...) \
SPDLOG_LOGGER_CALL( \
::Light::logger::get_file_logger(), \
2025-07-05 16:07:51 +03:30
spdlog::level::logLevel, \
__VA_ARGS__ \
2025-07-05 13:28:41 +03:30
)
#endif
namespace Light {
2025-07-05 16:07:51 +03:30
class logger
2025-07-05 13:28:41 +03:30
{
public:
static Scope<logger> create();
2025-07-05 13:28:41 +03:30
static inline Ref<spdlog::logger> get_engine_logger()
2025-07-05 13:28:41 +03:30
{
2025-07-05 16:07:51 +03:30
return s_context->m_engine_logger;
2025-07-05 13:28:41 +03:30
}
static inline Ref<spdlog::logger> get_file_logger()
2025-07-05 13:28:41 +03:30
{
2025-07-05 16:07:51 +03:30
return s_context->m_file_logger;
2025-07-05 13:28:41 +03:30
}
void log_debug_data();
2025-07-05 13:28:41 +03:30
private:
2025-07-05 16:07:51 +03:30
static logger *s_context;
Ref<spdlog::logger> m_engine_logger, m_file_logger;
std::string m_log_file_path;
logger();
2025-07-05 13:28:41 +03:30
};
} // namespace Light
#endif