我正在为正在构建的引擎制作日志系统,但遇到了问题。我为我的引擎设置了许多宏,但不幸的是,它们似乎不起作用。这是我的代码:Log.cpp
#include "Log.h"
#include "spdlog/sinks/stdout_color_sinks.h"
namespace Divided
{
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("DIVIDED");
s_CoreLogger->set_level(spdlog::level::trace);
s_ClientLogger = spdlog::stdout_color_mt("APP");
s_ClientLogger->set_level(spdlog::level::trace);
}
}
日志.h
#pragma once
#include <memory>
#include "Core.h"
#include "spdlog/spdlog.h"
namespace Divided
{
class DIVIDED_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 logging macros
#define DV_CORE_FATAL(...) ::Divided::Log::GetCoreLogger->fatal(__VA_ARGS__)
#define DV_CORE_ERROR(...) ::Divided::Log::GetCoreLogger->error(__VA_ARGS__)
#define DV_CORE_WARN(...) ::Divided::Log::GetCoreLogger->warn(__VA_ARGS__)
#define DV_CORE_INFO(...) ::Divided::Log::GetCoreLogger->info(__VA_ARGS__)
#define DV_CORE_TRACE(...) ::Divided::Log::GetCoreLogger->trace(__VA_ARGS__)
::
//client logging macros ::
#define DV_FATAL(...) ::Divided::Log::GetClientLogger->fatal(__VA_ARGS__)
#define DV_ERROR(...) ::Divided::Log::GetClientLogger->error(__VA_ARGS__)
#define DV_WARN(...) ::Divided::Log::GetClientLogger->warn(__VA_ARGS__)
#define DV_INFO(...) ::Divided::Log::GetClientLogger->info(__VA_ARGS__)
#define DV_TRACE(...) ::Divided::Log::GetClientLogger->trace(__VA_ARGS__)
和core.h
#pragma once
#ifdef DV_PLATFORM_WINDOWS
#ifdef DV_BUILD_DLL
#define DIVIDED_API __declspec(dllexport)
#else
#define DIVIDED_API __declspec(dllimport)
#endif
#else
#error DIVIDED ONLY SUPPORTS WINDOWS!
#endif
当我调用任何宏时,visual studio 说左边 ->
必须指向一个数据类型。有谁知道这是为什么刹车