mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-23 02:22:31 +00:00
log_sys to logger
enum DebugLevel {
General = 0, /* 0 - Low-Level general debugging, useful info on single line */
Moderate, /* 1 - Informational based, used in functions, when particular things load */
Detail, /* 2 - Use this for extreme detail in logging, usually in extreme debugging in the stack or interprocess communication */
};
void EQEmuLogSys::LogDebug(DebugLevel debug_level, std::string message, ...)
This commit is contained in:
parent
b8ed29c600
commit
84741e4cb1
@ -90,21 +90,35 @@ void EQEmuLogSys::StartZoneLogs(const std::string log_name)
|
|||||||
process_log.open(StringFormat("logs/zone/%s.txt", log_name.c_str()), std::ios_base::app | std::ios_base::out);
|
process_log.open(StringFormat("logs/zone/%s.txt", log_name.c_str()), std::ios_base::app | std::ios_base::out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQEmuLogSys::Log(uint16 log_type, const std::string message)
|
void EQEmuLogSys::LogDebug(DebugLevel debug_level, std::string message, ...){
|
||||||
|
va_list args;
|
||||||
|
va_start(args, message);
|
||||||
|
std::string output_message = vStringFormat(message.c_str(), args);
|
||||||
|
va_end(args);
|
||||||
|
EQEmuLogSys::Log(EQEmuLogSys::LogType::Debug, output_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQEmuLogSys::Log(uint16 log_type, const std::string message, ...)
|
||||||
{
|
{
|
||||||
if (log_type > EQEmuLogSys::MaxLogID){
|
if (log_type > EQEmuLogSys::MaxLogID){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!RuleB(Logging, LogFileCommands) && log_type == EQEmuLogSys::LogType::Commands){ return; }
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, message);
|
||||||
|
std::string output_message = vStringFormat(message.c_str(), args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
auto t = std::time(nullptr);
|
auto t = std::time(nullptr);
|
||||||
auto tm = *std::localtime(&t);
|
auto tm = *std::localtime(&t);
|
||||||
EQEmuLogSys::ConsoleMessage(log_type, message);
|
EQEmuLogSys::ConsoleMessage(log_type, message);
|
||||||
|
|
||||||
if (process_log){
|
if (process_log){
|
||||||
process_log << std::put_time(&tm, "[%d-%m-%Y :: %H:%M:%S] ") << StringFormat("[%s] ", TypeNames[log_type]).c_str() << message << std::endl;
|
process_log << std::put_time(&tm, "[%d-%m-%Y :: %H:%M:%S] ") << StringFormat("[%s] ", TypeNames[log_type]).c_str() << output_message << std::endl;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
std::cout << "[DEBUG] " << " :: There currently is no log file open for this process " << std::endl;
|
std::cout << "[DEBUG] " << ":: There currently is no log file open for this process " << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,23 +127,21 @@ void EQEmuLogSys::ConsoleMessage(uint16 log_type, const std::string message)
|
|||||||
if (log_type > EQEmuLogSys::MaxLogID){
|
if (log_type > EQEmuLogSys::MaxLogID){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!RuleB(Logging, ConsoleLogCommands) && log_type == EQEmuLogSys::LogType::Commands){ return; }
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
HANDLE console_handle;
|
HANDLE console_handle;
|
||||||
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
CONSOLE_FONT_INFOEX info = { 0 };
|
CONSOLE_FONT_INFOEX info = { 0 };
|
||||||
info.cbSize = sizeof(info);
|
info.cbSize = sizeof(info);
|
||||||
info.dwFontSize.Y = 12; // leave X as zero
|
info.dwFontSize.Y = 12; // leave X as zero
|
||||||
info.FontWeight = FW_NORMAL;
|
info.FontWeight = FW_NORMAL;
|
||||||
wcscpy(info.FaceName, L"Lucida Console");
|
wcscpy(info.FaceName, L"Lucida Console");
|
||||||
SetCurrentConsoleFontEx(console_handle, NULL, &info);
|
SetCurrentConsoleFontEx(console_handle, NULL, &info);
|
||||||
|
SetConsoleTextAttribute(console_handle, LogColors[log_type]);
|
||||||
SetConsoleTextAttribute(console_handle, LogColors[log_type]);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::cout << "[(N)" << TypeNames[log_type] << "] " << message << std::endl;
|
std::cout << "[N::" << TypeNames[log_type] << "] " << message << std::endl;
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
/* Always set back to white*/
|
/* Always set back to white*/
|
||||||
|
|||||||
@ -40,17 +40,25 @@ public:
|
|||||||
MaxLogID /* Max, used in functions to get the max log ID */
|
MaxLogID /* Max, used in functions to get the max log ID */
|
||||||
};
|
};
|
||||||
|
|
||||||
void StartZoneLogs(const std::string log_name);
|
enum DebugLevel {
|
||||||
void Log(uint16 log_type, const std::string message);
|
General = 0, /* 0 - Low-Level general debugging, useful info on single line */
|
||||||
|
Moderate, /* 1 - Informational based, used in functions, when particular things load */
|
||||||
|
Detail, /* 2 - Use this for extreme detail in logging, usually in extreme debugging in the stack or interprocess communication */
|
||||||
|
};
|
||||||
|
|
||||||
void CloseZoneLogs();
|
void CloseZoneLogs();
|
||||||
void ConsoleMessage(uint16 log_type, const std::string message);
|
void ConsoleMessage(uint16 log_type, const std::string message);
|
||||||
|
void LogDebug(DebugLevel debug_level, std::string message, ...);
|
||||||
|
void Log(uint16 log_type, const std::string message, ...);
|
||||||
|
void StartZoneLogs(const std::string log_name);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool zone_general_init = false;
|
bool zone_general_init = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EQEmuLogSys log_sys;
|
extern EQEmuLogSys logger;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -103,7 +103,7 @@ TitleManager title_manager;
|
|||||||
QueryServ *QServ = 0;
|
QueryServ *QServ = 0;
|
||||||
TaskManager *taskmanager = 0;
|
TaskManager *taskmanager = 0;
|
||||||
QuestParserCollection *parse = 0;
|
QuestParserCollection *parse = 0;
|
||||||
EQEmuLogSys log_sys;
|
EQEmuLogSys logger;
|
||||||
|
|
||||||
const SPDat_Spell_Struct* spells;
|
const SPDat_Spell_Struct* spells;
|
||||||
void LoadSpells(EQEmu::MemoryMappedFile **mmf);
|
void LoadSpells(EQEmu::MemoryMappedFile **mmf);
|
||||||
@ -146,6 +146,8 @@ int main(int argc, char** argv) {
|
|||||||
worldserver.SetLauncherName("NONE");
|
worldserver.SetLauncherName("NONE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_log(ZONE__INIT, "Loading server configuration..");
|
_log(ZONE__INIT, "Loading server configuration..");
|
||||||
if (!ZoneConfig::LoadConfig()) {
|
if (!ZoneConfig::LoadConfig()) {
|
||||||
_log(ZONE__INIT_ERR, "Loading server configuration failed.");
|
_log(ZONE__INIT_ERR, "Loading server configuration failed.");
|
||||||
@ -174,6 +176,8 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
GuildBanks = nullptr;
|
GuildBanks = nullptr;
|
||||||
|
|
||||||
|
logger.LogDebug(EQEmuLogSys::DebugLevel::General, "This is a crazy test message, database is %s and username is %s", Config->DatabaseDB.c_str(), Config->DatabaseUsername.c_str());
|
||||||
|
|
||||||
#ifdef _EQDEBUG
|
#ifdef _EQDEBUG
|
||||||
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -152,7 +152,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
|
|||||||
|
|
||||||
/* Set Logging */
|
/* Set Logging */
|
||||||
|
|
||||||
log_sys.StartZoneLogs(StringFormat("%s_ver-%u_instid-%u_port-%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort));
|
logger.StartZoneLogs(StringFormat("%s_ver-%u_instid-%u_port-%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -720,7 +720,7 @@ void Zone::Shutdown(bool quite)
|
|||||||
parse->ReloadQuests(true);
|
parse->ReloadQuests(true);
|
||||||
UpdateWindowTitle();
|
UpdateWindowTitle();
|
||||||
|
|
||||||
log_sys.CloseZoneLogs();
|
logger.CloseZoneLogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Zone::LoadZoneDoors(const char* zone, int16 version)
|
void Zone::LoadZoneDoors(const char* zone, int16 version)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user