[go: up one dir, main page]

Skip to content

maddinat0r/samp-log-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status

What is this?

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).

I'm just a normal SA-MP scripter; what do I have to do with this?

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).

I'm a plugin developer; what do I need to use this library?

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();
}

used server configuration variables

  • logtimeformat (using the same variable as the SA-MP server): uses the specified formatting for the date/time string of a log message
  • logcore_debuginfo: when set to 0, disables all additional debug info functionality, even if a AMX file is compiled with debug informations (basically renders all functions in header DebugInfo.hpp useless, they always return false)

Thanks to: