Установка через sampctl
sampctl package install philip1337/samp-plugin-spdlog
Выполните в папке проекта. sampctl скачает пакет и его зависимости.
readme.md
Log API (spdlog) for San Andreas Multiplayer
This plugin allows you to use the spdlog library in a sa-mp gamemode. It's still work in progress, not all spdlog features are implemented yet.
Features
- Very fast
- Format strings directly (no use of sprintf anymore)
- Multi/Single threaded output
- Various log systems
- Change log levels at runtime
- More features..
Various log systems
| native | params | return |
|---|---|---|
| ConsoleLogger | const name[] | int (1=success / 0=failed) |
| BasicLogger | const name[], const path[] | int (1=success / 0=failed) |
| RotatingLogger | const name[], const path[], time, files | int (1=success / 0=failed) |
| DailyLogger | const name[], const path[], hour, minute | int (1=success / 0=failed) |
| SysLogger (SPDLOG_ENABLE_SYSLOG) | const name[], const path[], pid | int (1=success / 0=failed) |
Change log settings
| native | params | return |
|---|---|---|
| DropAllLogger (At plugin unload this function gets called) | - | - |
| LoggerSetAsyncMode | bytes | - |
| LoggerSetAsyncModeIntervaled | bytes, seconds | - |
| LoggerSetPattern | const pattern[] | - |
| LoggerSetLevel | SPDLOG_LEVEL:level | - |
| EnableErrorLogger (Prints spdlog errors) | - | - |
Different log types
| native | params | return | level |
|---|---|---|---|
| LogInfo | const name[], const message[], {Float,_}:... | int int (1/0) | 2 |
| LogWarn | const name[], const message[], {Float,_}:... | int int (1/0) | 3 |
| LogCritical | const name[], const message[], {Float,_}:... | int int (1/0) | 5 |
| LogDebug | const name[], const message[], {Float,_}:... | int int (1/0) | 1 |
| LogTrace | const name[], const message[], {Float,_}:... | int int (1/0) | 0 |
| LogError | const name[], const message[], {Float,_}:... | int int (1/0) | 4 |
Flush properties for logger
| native | params | return |
|---|---|---|
| LogFlushOn | const name[], SPDLOG_LEVEL:level | int int (1/0) |
| LogFlush | const name[] | int int (1/0) |
Change the log level at runtime
If necessary, you can enable or disable the debugging output.
public OnPlayerCommandText(playerid, cmdtext[])
{
// Set log level to debug
if (strcmp("/debug", cmdtext, true, 6) == 0)
{
LoggerSetLevel(SPDLOG_LEVEL:DEBUG);
return 1;
}
// Unknown command
// LogWarn(Console, "Unknown command by pid(%d): %s", playerid, cmdtext);
return 0;
}
Access the same log from different filterscripts
If you have filterscripts, you can access the logger made from the gamemode just with the name.
Write logs outside the scriptfiles directory
You can create a new directory structure for logfiles. If you still want to save your logs at the scriptfiles directory, you need to write the path including "scriptfiles/".
Write console output without spamming the server_log.txt
#include <a_spdlog>
#define Console "stdout"
public OnGameModeInit()
{
// Enable async logging
LoggerSetAsyncMode(4096);
// Initialize logger
ConsoleLogger(Console); // To console (no log)
// Info (This text doesnt show up in server_log.txt)
LogInfo(Console, "Gamemode initializing...");
// Don't use these lines if it's a filterscript
SetGameModeText("SPDLog Test");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
// Info (This text doesnt show up in server_log.txt)
LogInfo(Console, "Gamemode initialized...");
LogInfo(Console, "Server started or whateverr...");
LogCritical(Console, "The server is burning! <- Colored console in samp 'WOW'");
return 1;
}
Build
Requirements
- Modified version of gclient
- CMake >=3.1
- C++11
- debian package: libc6-dev-i386
Synchronize dependencies from DEPS File.
gclient.py sync -v -f
You can also download it manually and place it into the external directory.
mkdir build
cd build
cmake ..\samp-log-spdlog
make
License
fastloglightweightpluginsampspdlog
Страница собрана из того, что GitHub публикует о репозитории. samp.directory не хранит этот код. Сообщить о проблеме с этой записью