samp.directory
← Скрипты и библиотеки

philip1337/samp-plugin-spdlog

Spdlog plugin for SA-MP

Плагин★ 8обновлён нояб. 2020 г.MITC++sampctl
Открыть на GitHub

Установка через 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

nativeparamsreturn
ConsoleLoggerconst name[]int (1=success / 0=failed)
BasicLoggerconst name[], const path[]int (1=success / 0=failed)
RotatingLoggerconst name[], const path[], time, filesint (1=success / 0=failed)
DailyLoggerconst name[], const path[], hour, minuteint (1=success / 0=failed)
SysLogger (SPDLOG_ENABLE_SYSLOG)const name[], const path[], pidint (1=success / 0=failed)

Change log settings

nativeparamsreturn
DropAllLogger (At plugin unload this function gets called)--
LoggerSetAsyncModebytes-
LoggerSetAsyncModeIntervaledbytes, seconds-
LoggerSetPatternconst pattern[]-
LoggerSetLevelSPDLOG_LEVEL:level-
EnableErrorLogger (Prints spdlog errors)--

Different log types

nativeparamsreturnlevel
LogInfoconst name[], const message[], {Float,_}:...int int (1/0)2
LogWarnconst name[], const message[], {Float,_}:...int int (1/0)3
LogCriticalconst name[], const message[], {Float,_}:...int int (1/0)5
LogDebugconst name[], const message[], {Float,_}:...int int (1/0)1
LogTraceconst name[], const message[], {Float,_}:...int int (1/0)0
LogErrorconst name[], const message[], {Float,_}:...int int (1/0)4

Flush properties for logger

nativeparamsreturn
LogFlushOnconst name[], SPDLOG_LEVEL:levelint int (1/0)
LogFlushconst 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

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 не хранит этот код. Сообщить о проблеме с этой записью