logging changed to spdlog

This commit is contained in:
d1str4ught
2025-09-22 04:14:59 +02:00
parent 37b15a7a98
commit 4f75aa1acd
201 changed files with 33830 additions and 637 deletions

View File

@@ -533,14 +533,6 @@ void config_init(const string& st_localeServiceName)
continue;
}
TOKEN("log_keep_days")
{
int i = 0;
str_to_number(i, value_string);
log_set_expiration_days(MINMAX(1, i, 90));
continue;
}
TOKEN("passes_per_sec")
{
str_to_number(passes_per_sec, value_string);
@@ -1041,10 +1033,6 @@ void config_init(const string& st_localeServiceName)
}
// END_SKILL_POWER_BY_LEVEL
// LOG_KEEP_DAYS_EXTEND
log_set_expiration_days(2);
// END_OF_LOG_KEEP_DAYS_EXTEND
while (fgets(buf, 256, fp))
{
parse_token(buf, token_string, value_string);

View File

@@ -426,6 +426,8 @@ static void CleanUpForEarlyExit() {
int main(int argc, char **argv)
{
log_init();
#ifdef DEBUG_ALLOC
DebugAllocator::StaticSetUp();
#endif
@@ -607,6 +609,7 @@ int main(int argc, char **argv)
DebugAllocator::StaticTearDown();
#endif
log_destroy();
return 1;
}
@@ -669,17 +672,6 @@ int start(int argc, char **argv)
optreset = 1;
break;
case 'l':
{
long l = strtol(argv[optind], &ep, 10);
log_set_level(l);
optind++;
optreset = 1;
}
break;
// LOCALE_SERVICE
case 'n':
{
@@ -868,25 +860,11 @@ int idle()
if (!io_loop(main_fdw)) return 0;
s_dwProfiler[PROF_IO] += (get_dword_time() - t);
log_rotate();
gettimeofday(&now, (struct timezone *) 0);
++process_time_count;
if (now.tv_sec - pta.tv_sec > 0)
{
pt_log("[%3d] event %5d/%-5d idle %-4ld event %-4ld heartbeat %-4ld I/O %-4ld chrUpate %-4ld | WRITE: %-7d | PULSE: %d",
process_time_count,
num_events_called,
event_count(),
thecore_profiler[PF_IDLE],
s_dwProfiler[PROF_EVENT],
s_dwProfiler[PROF_HEARTBEAT],
s_dwProfiler[PROF_IO],
s_dwProfiler[PROF_CHR_UPDATE],
current_bytes_written,
thecore_pulse());
num_events_called = 0;
current_bytes_written = 0;

View File

@@ -22,11 +22,7 @@
#include <filesystem>
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
namespace quest
{

View File

@@ -5,11 +5,7 @@
#include "char.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
namespace quest
{

View File

@@ -11,13 +11,8 @@
#include "desc_client.h"
#include "desc_manager.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
template <class Func> Func CDungeon::ForEachMember(Func f)
{

View File

@@ -9,11 +9,7 @@
#include "packet.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
extern ACMD(do_in_game_mall);

View File

@@ -25,12 +25,7 @@
#include "sectree_manager.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
extern ACMD(do_block_chat);
@@ -802,7 +797,7 @@ namespace quest
return 1;
}
// 새로운 state를 만든다.
// <EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD> state<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>.
int _set_quest_state(lua_State* L)
{
if (!lua_isstring(L, 1) || !lua_isstring(L, 2))
@@ -962,7 +957,7 @@ namespace quest
event_create(warp_all_to_village_event, info, PASSES_PER_SEC(iSec));
SendNoticeMap(LC_TEXT("잠시후 모두 마을로 이동됩니다."), iMapIndex, false);
SendNoticeMap(LC_TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̵<EFBFBD><CCB5>˴ϴ<CBB4>."), iMapIndex, false);
return 0;
}
@@ -1036,7 +1031,7 @@ namespace quest
return 0;
}
//주의: 몹 리젠이 안되는 맵에서만 사용
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ȵǴ<C8B5> <20>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
int _regen_in_map( lua_State * L )
{
int iMapIndex = static_cast<int>(lua_tonumber(L, 1));

View File

@@ -10,11 +10,7 @@
#include "guild_manager.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
namespace quest
{

View File

@@ -9,11 +9,7 @@
#include "utils.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
extern int (*check_name) (const char * str);

View File

@@ -7,11 +7,7 @@
#include "log.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
namespace quest
{

View File

@@ -7,11 +7,7 @@
#include "config.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
extern int g_nPortalLimitTime;

View File

@@ -17,11 +17,7 @@
#include "sectree_manager.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
ACMD(do_monarch_mob);

View File

@@ -9,11 +9,7 @@
#include "packet.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
namespace quest
{

View File

@@ -22,14 +22,10 @@
#include "utils.h"
#include "unique_item.h"
#include "mob_manager.h"
#include <cctype>
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
extern int g_nPortalLimitTime;
extern LPCLIENT_DESC db_clientdesc;

View File

@@ -11,11 +11,7 @@
#include "PetSystem.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
extern int (*check_name) (const char * str);

View File

@@ -4,11 +4,7 @@
#include "questmanager.h"
#undef sys_err
#ifndef OS_WINDOWS
#define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
#define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(std::source_location::current(), fmt __VA_OPT__(, __VA_ARGS__))
namespace quest
{

View File

@@ -1649,8 +1649,7 @@ namespace quest
GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_PARTY, "LUA_ERROR: quest %s.%s %s", GetCurrentQuestName().c_str(), state_name, event_index_name.c_str() );
}
#ifndef OS_WINDOWS
void CQuestManager::QuestError(const char* func, int line, const char* fmt, ...)
void CQuestManager::QuestError(const std::source_location& src_loc, const char* fmt, ...)
{
char szMsg[4096];
va_list args;
@@ -1659,39 +1658,17 @@ namespace quest
vsnprintf(szMsg, sizeof(szMsg), fmt, args);
va_end(args);
_sys_err(func, line, "%s", szMsg);
_sys_err(szMsg, src_loc);
if (test_server)
{
LPCHARACTER ch = GetCurrentCharacterPtr();
if (ch)
{
ch->ChatPacket(CHAT_TYPE_PARTY, "error occurred on [%s:%d]", func,line);
ch->ChatPacket(CHAT_TYPE_PARTY, "error occurred on [%s:%d]", src_loc.function_name(), src_loc.line());
ch->ChatPacket(CHAT_TYPE_PARTY, "%s", szMsg);
}
}
}
#else
void CQuestManager::QuestError(const char* func, int line, const char* fmt, ...)
{
char szMsg[4096];
va_list args;
va_start(args, fmt);
vsnprintf(szMsg, sizeof(szMsg), fmt, args);
va_end(args);
_sys_err(func, line, "%s", szMsg);
if (test_server)
{
LPCHARACTER ch = GetCurrentCharacterPtr();
if (ch)
{
ch->ChatPacket(CHAT_TYPE_PARTY, "error occurred on [%s:%d]", func,line);
ch->ChatPacket(CHAT_TYPE_PARTY, "%s", szMsg);
}
}
}
#endif
void CQuestManager::AddServerTimer(const std::string& name, DWORD arg, LPEVENT event)
{

View File

@@ -167,13 +167,7 @@ namespace quest
void ClearError() { m_bError = false; }
bool IsError() { return m_bError; }
void WriteRunningStateToSyserr();
#ifndef OS_WINDOWS
void QuestError(const char* func, int line, const char* fmt, ...);
#else
//void QuestError(const char* fmt, ...);
void QuestError(const char* func, int line, const char* fmt, ...);
#endif
void QuestError(const std::source_location& src_loc, const char* fmt, ...);
void RegisterNPCVnum(DWORD dwVnum);
private: