From 9e4ef74dd553a3dcaa7d4e7d6aef6f570548844c Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sat, 10 Jan 2015 14:59:32 -0600 Subject: [PATCH] RULE_INT(Logging, DebugLogLevel, 0) /* Sets Debug Level, -1 = OFF, 0 = Low Level, 1 = Info, 2 = Extreme */ --- common/eqemu_logsys.cpp | 5 +++++ common/ruletypes.h | 4 ++-- zone/net.cpp | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/eqemu_logsys.cpp b/common/eqemu_logsys.cpp index 498526d3b..3806e49e4 100644 --- a/common/eqemu_logsys.cpp +++ b/common/eqemu_logsys.cpp @@ -91,10 +91,15 @@ void EQEmuLogSys::StartZoneLogs(const std::string log_name) } void EQEmuLogSys::LogDebug(DebugLevel debug_level, std::string message, ...){ + if (RuleI(Logging, DebugLogLevel) < debug_level){ + return; + } + 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); } diff --git a/common/ruletypes.h b/common/ruletypes.h index aa9a83c72..1d9286a69 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -599,6 +599,7 @@ RULE_CATEGORY_END() RULE_CATEGORY(Logging) RULE_BOOL(Logging, ConsoleLogCommands, false) /* Turns on or off console logs */ RULE_BOOL(Logging, LogFileCommands, false) +RULE_INT(Logging, DebugLogLevel, 0) /* Sets Debug Level, -1 = OFF, 0 = Low Level, 1 = Info, 2 = Extreme */ RULE_CATEGORY_END() @@ -606,5 +607,4 @@ RULE_CATEGORY_END() #undef RULE_INT #undef RULE_REAL #undef RULE_BOOL -#undef RULE_CATEGORY_END - +#undef RULE_CATEGORY_END \ No newline at end of file diff --git a/zone/net.cpp b/zone/net.cpp index cfd00628a..c9fd32a00 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -176,7 +176,11 @@ int main(int argc, char** argv) { 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()); + logger.LogDebug(EQEmuLogSys::General, "Test, Debug Log Level 0"); + logger.LogDebug(EQEmuLogSys::Moderate, "Test, Debug Log Level 1"); + logger.LogDebug(EQEmuLogSys::Detail, "Test, Debug Log Level 2"); + + logger.LogDebug(EQEmuLogSys::General, "This is a crazy test message, database is '%s' and port is %u", Config->DatabaseDB.c_str(), Config->DatabasePort); #ifdef _EQDEBUG _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);