This is a library which provides a full logging-system to be used in any SA-MP plugins. It can also use debug information in an AMX file to provide more information about a native-call (like in which PAWN file and on which line number it was called).
You just have to download the runtime package containing the library and put it in the root folder of your SA-MP server (where the SA-MP server executable is).
You have to download the normal package, use the include files in your project and link the library with your plugin. Here is a small example on how you could use this library in your plugin:
#include <samplog/PluginLogger.h>
using samplog::LogLevel;
samplog::CPluginLogger logger("my-plugin-name");
// native MyNativeFunction(int_param, Float:float_param, const string_param[]);
cell AMX_NATIVE_CALL MyNativeFunction(AMX *amx, cell *params)
{
logger.Log(LogLevel::WARNING, "simple warning message");
logger.Log(amx, LogLevel::ERROR, "error message with debug info (line number, file) appended");
//logs the native call with the actual passed values as debug message
logger.LogNativeCall(amx, params, "MyNativeFunction", "dfs");
//possible log message:
// "[<datetime>] [DEBUG] MyNativeFunction(123, 45.6789, "mystring") (my-script.pwn:43)"
return 1;
}
PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
{
samplog::Init();
return true;
}
PLUGIN_EXPORT void PLUGIN_CALL Unload()
{
samplog::Exit();
}
logtimeformat
(using the same variable as the SA-MP server): uses the specified formatting for the date/time string of a log messagelogcore_debuginfo
: when set to0
, disables all additional debug info functionality, even if a AMX file is compiled with debug informations (basically renders all functions in headerDebugInfo.hpp
useless, they always returnfalse
)
- Zeex' crashdetect (many useful things about AMX structure and debug info there!)
- KjellKod's crash-handler code (taken from g3log) (heavily modified by now)
- vitaut's fmt