Skip to content

3. Logger

DK edited this page Sep 20, 2023 · 1 revision

Logger Source

Some macro style loggers with spdlog backend.

Init

// by default the log directory is current process path
// this can be manually overriden
#define LOG_PATH "logs\\"
#include "DKUtil/Logger.hpp"

DKUtil::Logger::Init(NameString, VersionString);

macro

TRACE("trace {}", debugVal);
INFO("{} {} {} {}", a, b, c, d);
DEBUG("Important debug info that shows on debug build"sv);
WARN("Generate warnings in log");
ERROR("This will prompt for exit!");
FATAL("This will abort with message.");

ENABLE_DEBUG
// debug logs from here will be printed
DISABLE_DEBUG
// debug logs from here will be omitted

// or change log level manually
DKUtil::Logger::SetLevel(spdlog::level::level_enums);

For fmt syntax, refer to fmtlib syntax.