MIT License

项目介绍

philip1337/samp-plugin-spdlog 是一个托管在 GitHub 上的开源项目,主要使用 C++ 编写,采用 MIT License 许可证,目前获得 8 个 Star、2 次 Fork。

仓库全名
philip1337/samp-plugin-spdlog
开源许可证
MIT License
Star 数
8
Fork 数
2
未关闭 Issue
2

README 摘要

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. Gabime/spdlog Benchmark of spdlog Test gamemode 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…

完整内容见 GitHub 原始 README 或本页 。

常见问题

samp-plugin-spdlog 用什么语言开发?

主要使用 C++ 编写,采用 MIT License 许可证,目前有 8 个 Star。

samp-plugin-spdlog 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 samp-plugin-spdlog 的源码?

可以直接克隆仓库:git clone https://github.com/philip1337/samp-plugin-spdlog.git,默认分支为 master;安装与运行步骤见仓库 README。

samp-plugin-spdlog 最近还在维护吗?

仓库最近一次更新为 2020年11月16日,当前有 2 个未关闭 Issue;Star 数为 8,可作为社区活跃度的参考。

关于

Spdlog plugin for SA-MP

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
14
价值分
5
活跃状态
活跃

语言占比

C++
CMake
Pawn
Python

Release

README

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

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

评论

暂无评论