Convert missed files in logic to use logger from logic.
This commit is contained in:
parent
486910a9a1
commit
e4645332aa
@ -32,6 +32,7 @@
|
|||||||
#include <IPluginSys.h>
|
#include <IPluginSys.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "DebugReporter.h"
|
#include "DebugReporter.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
DebugReport g_DbgReporter;
|
DebugReport g_DbgReporter;
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ void DebugReport::OnDebugSpew(const char *msg, ...)
|
|||||||
smcore.FormatArgs(buffer, sizeof(buffer), msg, ap);
|
smcore.FormatArgs(buffer, sizeof(buffer), msg, ap);
|
||||||
va_end(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, ...)
|
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)
|
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 {
|
} 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)
|
if (func_idx != -1)
|
||||||
{
|
{
|
||||||
@ -86,7 +87,7 @@ void DebugReport::GenerateErrorVA(IPluginContext *ctx, cell_t func_idx, int err,
|
|||||||
sp_public_t *function;
|
sp_public_t *function;
|
||||||
if (ctx->GetRuntime()->GetPublicByIndex(func_idx, &function) == SP_ERROR_NONE)
|
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)
|
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 {
|
} 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;
|
IPluginDebugInfo *pDebug;
|
||||||
if ((pDebug = pContext->GetRuntime()->GetDebugInfo()) == NULL)
|
if ((pDebug = pContext->GetRuntime()->GetDebugInfo()) == NULL)
|
||||||
{
|
{
|
||||||
smcore.LogError("[SM] Debug mode is not enabled for \"%s\"", plname);
|
g_Logger.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] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on",
|
||||||
_GetPluginIndex(pContext));
|
_GetPluginIndex(pContext));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -125,9 +126,9 @@ void DebugReport::GenerateCodeError(IPluginContext *pContext, uint32_t code_addr
|
|||||||
const char *name;
|
const char *name;
|
||||||
if (pDebug->LookupFunction(code_addr, &name) == SP_ERROR_NONE)
|
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 {
|
} 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)
|
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,
|
n_err,
|
||||||
error->GetErrorString());
|
error->GetErrorString());
|
||||||
}
|
}
|
||||||
@ -149,26 +150,26 @@ void DebugReport::OnContextExecuteError(IPluginContext *ctx, IContextTrace *erro
|
|||||||
const char *custerr;
|
const char *custerr;
|
||||||
if ((custerr=error->GetCustomErrorString()) != NULL)
|
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 {
|
} 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())
|
if (!error->DebugInfoAvailable())
|
||||||
{
|
{
|
||||||
smcore.LogError("[SM] Debug mode is not enabled for \"%s\"", plname);
|
g_Logger.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] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on",
|
||||||
_GetPluginIndex(ctx));
|
_GetPluginIndex(ctx));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CallStackInfo stk_info;
|
CallStackInfo stk_info;
|
||||||
int i = 0;
|
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))
|
while (error->GetTraceInfo(&stk_info))
|
||||||
{
|
{
|
||||||
smcore.LogError("[SM] [%d] Line %d, %s::%s()",
|
g_Logger.LogError("[SM] [%d] Line %d, %s::%s()",
|
||||||
i++,
|
i++,
|
||||||
stk_info.line,
|
stk_info.line,
|
||||||
stk_info.filename,
|
stk_info.filename,
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "GameConfigs.h"
|
#include "GameConfigs.h"
|
||||||
#include "common_logic.h"
|
#include "common_logic.h"
|
||||||
#include "Translator.h"
|
#include "Translator.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
CPluginManager g_PluginSys;
|
CPluginManager g_PluginSys;
|
||||||
HandleType_t g_PluginType = 0;
|
HandleType_t g_PluginType = 0;
|
||||||
@ -844,8 +845,8 @@ void CPluginManager::LoadPluginsFromDir(const char *basedir, const char *localpa
|
|||||||
{
|
{
|
||||||
char error[256];
|
char error[256];
|
||||||
libsys->GetPlatformError(error, sizeof(error));
|
libsys->GetPlatformError(error, sizeof(error));
|
||||||
smcore.LogError("[SM] Failure reading from plugins path: %s", localpath);
|
g_Logger.LogError("[SM] Failure reading from plugins path: %s", localpath);
|
||||||
smcore.LogError("[SM] Platform returned error: %s", error);
|
g_Logger.LogError("[SM] Platform returned error: %s", error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,9 +991,9 @@ LoadRes CPluginManager::_LoadPlugin(CPlugin **aResult, const char *path, bool de
|
|||||||
} else {
|
} else {
|
||||||
if (bulletinUrl[0] != '\0')
|
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 {
|
} 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)
|
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->SetErrorState(
|
||||||
pl->GetStatus() <= Plugin_Created ? Plugin_BadLoad : pl->GetStatus(),
|
pl->GetStatus() <= Plugin_Created ? Plugin_BadLoad : pl->GetStatus(),
|
||||||
"%s",
|
"%s",
|
||||||
@ -1136,7 +1137,7 @@ void CPluginManager::LoadAll_SecondPass()
|
|||||||
error[0] = '\0';
|
error[0] = '\0';
|
||||||
if (!RunSecondPass(pPlugin, error, sizeof(error)))
|
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);
|
pPlugin->SetErrorState(Plugin_Failed, "%s", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user