r5sdk/r5dev/core/logdef.cpp
Kawe Mazidjatari f2a5c8ac68 See description
* Renamed 'r5apexsdkd64.dll' to 'gamesdk.dll'.
* Added required dedicated parameters to code instead.
* Bug fixes around CCommandLine class (fixed misaligned VTable indexes).
* SDK now supports being directly launched by the game executable.

The SDK launcher will pass '-launcher' to the game, which indicated its being launched by the launcher. If the game does not receive '-launcher', it assumes its being launched directly from the game executable, which will instead load 'startup_(dedi_)default.cfg'.

The sdk dll's are now added to the game's IAT by their dummy exports allowing for them to be loaded when the exe is loaded (the dll's do everything on init).
2022-04-16 00:30:46 +02:00

63 lines
2.9 KiB
C++

#include "core/stdafx.h"
#include "core/logdef.h"
//#############################################################################
// SPDLOG SETUP
//#############################################################################
void SpdLog_Init(void)
{
static bool bInitialized = false;
if (bInitialized)
{
Assert(bInitialized, "'SpdLog_Init()' has already been called.");
return;
}
/************************
* IMGUI LOGGER SETUP *
************************/
{
auto iconsole = std::make_shared<spdlog::logger>("game_console", g_spd_sys_p_ostream_sink);
spdlog::register_logger(iconsole); // in-game console logger.
iconsole->set_pattern("[%S.%e] %v");
iconsole->set_level(spdlog::level::trace);
}
/************************
* WINDOWS LOGGER SETUP *
************************/
{
auto wconsole = spdlog::stdout_logger_mt("win_console");
// Determine if user wants ansi-color logging in the terminal.
if (strstr(g_svCmdLine.c_str(), "-ansiclr"))
{
wconsole->set_pattern("[%S.%e] %v\u001b[0m");
g_bSpdLog_UseAnsiClr = true;
}
else { wconsole->set_pattern("[%S.%e] %v"); }
wconsole->set_level(spdlog::level::trace);
spdlog::set_default_logger(wconsole); // Set as default.
}
/************************
* ROTATE LOGGER SETUP *
************************/
{
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sqvm_warn_logger", "platform\\logs\\sqvm_warn.log", SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sqvm_print_logger", "platform\\logs\\sqvm_print.log", SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("dev_message_logger", "platform\\logs\\dev_message.log", SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("warn_message_logger", "platform\\logs\\sdk_warn.log", SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("error_message_logger", "platform\\logs\\sdk_error.log", SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("qhull_debug_logger", "platform\\logs\\qhull_print.log", SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("netchan_packet_logger", "platform\\logs\\net_trace.log", SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("filesystem_warn_logger", "platform\\logs\\fs_warn.log", SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
}
spdlog::set_level(spdlog::level::trace);
spdlog::flush_every(std::chrono::seconds(5)); // Flush buffers every 5 seconds for every logger.
bInitialized = true;
}