From e4645332aa625e7b325e90e394752af47e791cdf Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 17 Aug 2014 11:06:43 -0400 Subject: [PATCH] Convert missed files in logic to use logger from logic. --- core/logic/DebugReporter.cpp | 39 ++++++++++++++++++------------------ core/logic/PluginSys.cpp | 13 ++++++------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/core/logic/DebugReporter.cpp b/core/logic/DebugReporter.cpp index efeea02d..ef5863ba 100644 --- a/core/logic/DebugReporter.cpp +++ b/core/logic/DebugReporter.cpp @@ -32,6 +32,7 @@ #include #include #include "DebugReporter.h" +#include "Logger.h" DebugReport g_DbgReporter; @@ -49,7 +50,7 @@ void DebugReport::OnDebugSpew(const char *msg, ...) smcore.FormatArgs(buffer, sizeof(buffer), msg, ap); va_end(ap); - smcore.Log("[SM] %s", buffer); + g_Logger.LogMessage("[SM] %s", buffer); } void DebugReport::GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...) @@ -71,12 +72,12 @@ void DebugReport::GenerateErrorVA(IPluginContext *ctx, cell_t func_idx, int err, if (error) { - smcore.LogError("[SM] Plugin \"%s\" encountered error %d: %s", plname, err, error); + g_Logger.LogError("[SM] Plugin \"%s\" encountered error %d: %s", plname, err, error); } else { - smcore.LogError("[SM] Plugin \"%s\" encountered unknown error %d", plname, err); + g_Logger.LogError("[SM] Plugin \"%s\" encountered unknown error %d", plname, err); } - smcore.LogError("[SM] %s", buffer); + g_Logger.LogError("[SM] %s", buffer); if (func_idx != -1) { @@ -86,7 +87,7 @@ void DebugReport::GenerateErrorVA(IPluginContext *ctx, cell_t func_idx, int err, sp_public_t *function; if (ctx->GetRuntime()->GetPublicByIndex(func_idx, &function) == SP_ERROR_NONE) { - smcore.LogError("[SM] Unable to call function \"%s\" due to above error(s).", function->name); + g_Logger.LogError("[SM] Unable to call function \"%s\" due to above error(s).", function->name); } } } @@ -106,18 +107,18 @@ void DebugReport::GenerateCodeError(IPluginContext *pContext, uint32_t code_addr if (error) { - smcore.LogError("[SM] Plugin \"%s\" encountered error %d: %s", plname, err, error); + g_Logger.LogError("[SM] Plugin \"%s\" encountered error %d: %s", plname, err, error); } else { - smcore.LogError("[SM] Plugin \"%s\" encountered unknown error %d", plname, err); + g_Logger.LogError("[SM] Plugin \"%s\" encountered unknown error %d", plname, err); } - smcore.LogError("[SM] %s", buffer); + g_Logger.LogError("[SM] %s", buffer); IPluginDebugInfo *pDebug; if ((pDebug = pContext->GetRuntime()->GetDebugInfo()) == NULL) { - smcore.LogError("[SM] Debug mode is not enabled for \"%s\"", plname); - smcore.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on", + g_Logger.LogError("[SM] Debug mode is not enabled for \"%s\"", plname); + g_Logger.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on", _GetPluginIndex(pContext)); return; } @@ -125,9 +126,9 @@ void DebugReport::GenerateCodeError(IPluginContext *pContext, uint32_t code_addr const char *name; if (pDebug->LookupFunction(code_addr, &name) == SP_ERROR_NONE) { - smcore.LogError("[SM] Unable to call function \"%s\" due to above error(s).", name); + g_Logger.LogError("[SM] Unable to call function \"%s\" due to above error(s).", name); } else { - smcore.LogError("[SM] Unable to call function (name unknown, address \"%x\").", code_addr); + g_Logger.LogError("[SM] Unable to call function (name unknown, address \"%x\").", code_addr); } } @@ -139,7 +140,7 @@ void DebugReport::OnContextExecuteError(IPluginContext *ctx, IContextTrace *erro if (n_err != SP_ERROR_NATIVE) { - smcore.LogError("[SM] Plugin encountered error %d: %s", + g_Logger.LogError("[SM] Plugin encountered error %d: %s", n_err, error->GetErrorString()); } @@ -149,26 +150,26 @@ void DebugReport::OnContextExecuteError(IPluginContext *ctx, IContextTrace *erro const char *custerr; if ((custerr=error->GetCustomErrorString()) != NULL) { - smcore.LogError("[SM] Native \"%s\" reported: %s", lastname, custerr); + g_Logger.LogError("[SM] Native \"%s\" reported: %s", lastname, custerr); } else { - smcore.LogError("[SM] Native \"%s\" encountered a generic error.", lastname); + g_Logger.LogError("[SM] Native \"%s\" encountered a generic error.", lastname); } } if (!error->DebugInfoAvailable()) { - smcore.LogError("[SM] Debug mode is not enabled for \"%s\"", plname); - smcore.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on", + g_Logger.LogError("[SM] Debug mode is not enabled for \"%s\"", plname); + g_Logger.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on", _GetPluginIndex(ctx)); return; } CallStackInfo stk_info; int i = 0; - smcore.LogError("[SM] Displaying call stack trace for plugin \"%s\":", plname); + g_Logger.LogError("[SM] Displaying call stack trace for plugin \"%s\":", plname); while (error->GetTraceInfo(&stk_info)) { - smcore.LogError("[SM] [%d] Line %d, %s::%s()", + g_Logger.LogError("[SM] [%d] Line %d, %s::%s()", i++, stk_info.line, stk_info.filename, diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index 2e7f45e4..c53d4fe3 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -42,6 +42,7 @@ #include "GameConfigs.h" #include "common_logic.h" #include "Translator.h" +#include "Logger.h" CPluginManager g_PluginSys; HandleType_t g_PluginType = 0; @@ -844,8 +845,8 @@ void CPluginManager::LoadPluginsFromDir(const char *basedir, const char *localpa { char error[256]; libsys->GetPlatformError(error, sizeof(error)); - smcore.LogError("[SM] Failure reading from plugins path: %s", localpath); - smcore.LogError("[SM] Platform returned error: %s", error); + g_Logger.LogError("[SM] Failure reading from plugins path: %s", localpath); + g_Logger.LogError("[SM] Platform returned error: %s", error); return; } @@ -990,9 +991,9 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **aResult, const char *path, bool de } else { if (bulletinUrl[0] != '\0') { - smcore.Log("%s: Known malware detected. See %s for more info, blocking disabled in core.cfg", pPlugin->GetFilename(), bulletinUrl); + g_Logger.LogMessage("%s: Known malware detected. See %s for more info, blocking disabled in core.cfg", pPlugin->GetFilename(), bulletinUrl); } else { - smcore.Log("%s: Possible malware or illegal plugin detected, blocking disabled in core.cfg", pPlugin->GetFilename()); + g_Logger.LogMessage("%s: Possible malware or illegal plugin detected, blocking disabled in core.cfg", pPlugin->GetFilename()); } } } @@ -1094,7 +1095,7 @@ void CPluginManager::LoadAutoPlugin(const char *plugin) if ((res=_LoadPlugin(&pl, plugin, false, PluginType_MapUpdated, error, sizeof(error))) == LoadRes_Failure) { - smcore.LogError("[SM] Failed to load plugin \"%s\": %s.", plugin, error); + g_Logger.LogError("[SM] Failed to load plugin \"%s\": %s.", plugin, error); pl->SetErrorState( pl->GetStatus() <= Plugin_Created ? Plugin_BadLoad : pl->GetStatus(), "%s", @@ -1136,7 +1137,7 @@ void CPluginManager::LoadAll_SecondPass() error[0] = '\0'; if (!RunSecondPass(pPlugin, error, sizeof(error))) { - smcore.LogError("[SM] Unable to load plugin \"%s\": %s", pPlugin->GetFilename(), error); + g_Logger.LogError("[SM] Unable to load plugin \"%s\": %s", pPlugin->GetFilename(), error); pPlugin->SetErrorState(Plugin_Failed, "%s", error); } }