Reworked SDK LogError() to include module names

improved debugging output
This commit is contained in:
David Anderson 2004-10-04 05:50:28 +00:00
parent bb12f71137
commit b9c83aa4a2
4 changed files with 27 additions and 13 deletions

View File

@ -1190,7 +1190,8 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
if (!dbg || !(dbg->tail)) if (!dbg || !(dbg->tail))
{ {
GenericError(amx, err, amx->curline, buf, NULL); GenericError(amx, err, amx->curline, buf, NULL);
AMXXLOG_Log("[AMXX] %s %s", buf, vbuf); AMXXLOG_Log("[AMXX] %s", buf);
AMXXLOG_Log("%s", vbuf);
} else { } else {
AMX_TRACE *t = dbg->tail; AMX_TRACE *t = dbg->tail;
AMX_DEBUGCALL tracer = (AMX_DEBUGCALL)(amx->userdata[1]); AMX_DEBUGCALL tracer = (AMX_DEBUGCALL)(amx->userdata[1]);
@ -1198,19 +1199,20 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
cell line = amx->curline; cell line = amx->curline;
cell file = amx->curfile; cell file = amx->curfile;
int i = 0; int i = 0;
if (file >= dbg->numFiles || file < 0)
{
GenericError(amx, err, line, buf, NULL); GenericError(amx, err, line, buf, NULL);
} else {
GenericError(amx, err, line, buf, dbg->files[file]);
}
AMXXLOG_Log("[AMXX] %s", buf); AMXXLOG_Log("[AMXX] %s", buf);
if (*vbuf) if (*vbuf)
{ {
AMXXLOG_Log("[AMXX] %s", vbuf); AMXXLOG_Log("%s", vbuf);
} }
AMXXLOG_Log("[AMXX] Debug Trace =>"); AMXXLOG_Log("[AMXX] Debug Trace =>");
//log the error right away //log the error right away
if (file >= dbg->numFiles || file < 0)
{
AMXXLOG_Log("[AMXX] [%d] Line %d, File \"%s\"", i++, line, g_plugins.findPluginFast(amx)->getName());
} else {
AMXXLOG_Log("[AMXX] [%d] Line %d, File \"%s\"", i++, line, dbg->files[file]);
}
while (t != NULL) while (t != NULL)
{ {
line = t->line; line = t->line;

View File

@ -316,7 +316,7 @@
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386" AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="odbc32.lib odbccp32.lib ..\jit\jits.lib ..\zlib\zlib.lib" AdditionalDependencies="..\jit\jits.obj ..\zlib\zlib.lib"
OutputFile="jitdebug/amxmodx_mm.dll" OutputFile="jitdebug/amxmodx_mm.dll"
Version="0.1" Version="0.1"
LinkIncremental="1" LinkIncremental="1"

View File

@ -2454,7 +2454,7 @@ PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
PFN_FORMAT_AMXSTRING g_fn_FormatAmxString; PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory; PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
PFN_LOG g_fn_Log; PFN_LOG g_fn_Log;
PFN_LOG_ERROR g_fn_LogError; PFN_LOG_ERROR g_fn_LogErrorFunc;
PFN_RAISE_AMXERROR g_fn_RaiseAmxError; PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
PFN_REGISTER_FORWARD g_fn_RegisterForward; PFN_REGISTER_FORWARD g_fn_RegisterForward;
PFN_EXECUTE_FORWARD g_fn_ExecuteForward; PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
@ -2544,7 +2544,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE); REQFUNC("PrintSrvConsole", g_fn_PrintSrvConsole, PFN_PRINT_SRVCONSOLE);
REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME); REQFUNC("GetModname", g_fn_GetModname, PFN_GET_MODNAME);
REQFUNC("Log", g_fn_Log, PFN_LOG); REQFUNC("Log", g_fn_Log, PFN_LOG);
REQFUNC("LogError", g_fn_LogError, PFN_LOG_ERROR); REQFUNC("LogError", g_fn_LogErrorFunc, PFN_LOG_ERROR);
REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE); REQFUNC("MergeDefinitionFile", g_fn_MergeDefinition_File, PFN_MERGEDEFINITION_FILE);
REQFUNC("Format", g_fn_Format, PFN_FORMAT); REQFUNC("Format", g_fn_Format, PFN_FORMAT);
@ -2651,6 +2651,18 @@ void MF_Log(const char *fmt, ...)
g_fn_Log("[%s] %s", MODULE_NAME, msg); g_fn_Log("[%s] %s", MODULE_NAME, msg);
} }
void MF_LogError(AMX *amx, int err, const char *fmt, ...)
{
// :TODO: Overflow possible here
char msg[3072];
va_list arglst;
va_start(arglst, fmt);
vsprintf(msg, fmt, arglst);
va_end(arglst);
g_fn_LogErrorFunc(amx, err, "[%s] %s", MODULE_NAME, msg);
}
#ifdef _DEBUG #ifdef _DEBUG
// validate macros // validate macros

View File

@ -1990,7 +1990,7 @@ extern PFN_GET_AMXSTRINGLEN g_fn_GetAmxStringLen;
extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString; extern PFN_FORMAT_AMXSTRING g_fn_FormatAmxString;
extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory; extern PFN_COPY_AMXMEMORY g_fn_CopyAmxMemory;
extern PFN_LOG g_fn_Log; extern PFN_LOG g_fn_Log;
extern PFN_LOG_ERROR g_fn_LogError; extern PFN_LOG_ERROR g_fn_LogErrorFunc;
extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError; extern PFN_RAISE_AMXERROR g_fn_RaiseAmxError;
extern PFN_REGISTER_FORWARD g_fn_RegisterForward; extern PFN_REGISTER_FORWARD g_fn_RegisterForward;
extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward; extern PFN_EXECUTE_FORWARD g_fn_ExecuteForward;
@ -2106,7 +2106,7 @@ const char * MF_Format (const char *fmt, ...) { }
#define MF_GetAmxStringLen g_fn_GetAmxStringLen #define MF_GetAmxStringLen g_fn_GetAmxStringLen
#define MF_CopyAmxMemory g_fn_CopyAmxMemory #define MF_CopyAmxMemory g_fn_CopyAmxMemory
void MF_Log(const char *fmt, ...); void MF_Log(const char *fmt, ...);
#define MF_LogError g_fn_LogError void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RaiseAmxError g_fn_RaiseAmxError #define MF_RaiseAmxError g_fn_RaiseAmxError
#define MF_RegisterForward g_fn_RegisterForward #define MF_RegisterForward g_fn_RegisterForward
#define MF_ExecuteForward g_fn_ExecuteForward #define MF_ExecuteForward g_fn_ExecuteForward