Skip to content

Releases: F1F88/sm-ext-log4sp

v1.7.0

19 Jan 12:18
Compare
Choose a tag to compare

Logger

Deprecated APIs

  • Removed async Logger feature (#21)

  • Removed BackTrace feature

    Logger.ShouldBacktrace
    Logger.EnableBacktrace
    Logger.DisableBacktrace
    Logger.DumpBacktrace
  • Removed constructor parameters sinks and numSinks (#24)

    Constructor is now mainly used to create an empty logger, to create with a list of sinks use Logger.CreateLoggerWith

    // v1.6.0
    public native Logger(const char[] name, Sink[] sinks, int numSinks);
    
    // v1.7.0
    public native Logger(const char[] name);
  • Migrate single Sink static factory method to Sink MethodMap

    // v1.6.0
    public static native Logger Logger.CreateBaseFileLogger()
    public static native Logger Logger.CreateDailyFileLogger()
    public static native Logger Logger.CreateRotatingFileLogger()
    public static native Logger Logger.CreateServerConsoleLogger()
    
    // v1.7.0
    public static native Logger BaseFileSink.CreateLogger()
    public static native Logger CallbackSink.CreateLogger()
    public static native Logger ClientChatAllSink.CreateLogger()
    public static native Logger ClientConsoleAllSink.CreateLogger()
    public static native Logger DailyFileSink.CreateLogger()
    public static native Logger RingBufferSink.CreateLogger()
    public static native Logger RotatingFileSink.CreateLogger()
    public static native Logger ServerConsoleSink.CreateLogger()

Improved APIs

  • Added Native Logger.CreateLoggerWith, Logger.CreateLoggerWithEx (#24)

  • Added Native Logger.AddSinkEx (#24)

Automatically release the parameter sink after adding sink successfully Handle

  • Added Native Logger.GetNameLength (#20)

  • Added Logger.ApplyAll optional data parameter (#18) (#20) (thanks @blueblur0730)

    // v1.6.0
    void ApplyAll(LoggerApplyAllCallback callback);
    
    // v1.7.0
    void ApplyAll(LoggerApplyAllCallback callback, any data = 0);
  • Added LoggerErrorHandler callback optional parameter (#24)

    // v1.6.0
    function void (const char[] msg);
    
    // v1.7.0
    function void (const char[] msg, const char[] name, const char[] file, int line, const char[] func);

Sink

  • Remove multithreading Sink (#21)

  • Remove MethodMap ClientChatSink, ClientConsoleSink (#21)

    For custom target requirements, please use CallbackSink

  • Added MethodMap ClientChatAllSink, ClientConsoleAllSink (#21)

  • Added MethodMap CallbackSink (#22) (#23)

  • Added MethodMap RingBufferSink (#25)

Chore
  • Added macro LOG4SP_GLOBAL_LOGGER_NAME

  • Added support for UTF8 encoding of logger names and file paths

  • New features LOG4SP_NO_EXT

    • Support outputting Off level logs

    • Support Logger.LogSrc and Logger.LogLoc

  • Fix a possible memory leak in Logger.ApplyAll

  • Fix incomplete log message of stack trace

  • Fix rare crash caused by underlying sink (#15) (#16)

  • Optimize operation efficiency (#24)

    • Logger.ApplyAll execution efficiency (slightly)

    • Logging operation execution efficiency (slightly)

    • Execution efficiency of non-output log level (significant)

    • Execution efficiency of base class sink Handle (significant)

  • Optimize compilation and build scripts (#17)

    • Compile and build efficiency

    • Generate binary file size

    • Migrate special macro definitions and tuning parameters to build scripts

    • Remove all modifications in "extern/spdlog"

    • Move test case files to testsuit folder

  • Unify project name "Log for SourcePawn"


Logger

弃用的 APIs

  • 移除异步 Logger 功能 (#21)

  • 移除回溯 (BackTrace) 功能

    Logger.ShouldBacktrace
    Logger.EnableBacktrace
    Logger.DisableBacktrace
    Logger.DumpBacktrace
  • 移除构造函数的参数 sinksnumSinks#24

    现在构造函数主要用于创建空 logger,要随 Sink 列表一起创建请使用 Logger.CreateLoggerWith

    // v1.6.0
    public native Logger(const char[] name, Sink[] sinks, int numSinks);
    
    // v1.7.0
    public native Logger(const char[] name);
  • 迁移单 Sink 的静态工厂方法到 Sink MethodMap

    // v1.6.0
    public static native Logger Logger.CreateBaseFileLogger()
    public static native Logger Logger.CreateDailyFileLogger()
    public static native Logger Logger.CreateRotatingFileLogger()
    public static native Logger Logger.CreateServerConsoleLogger()
    
    // v1.7.0
    public static native Logger BaseFileSink.CreateLogger()
    public static native Logger CallbackSink.CreateLogger()
    public static native Logger ClientChatAllSink.CreateLogger()
    public static native Logger ClientConsoleAllSink.CreateLogger()
    public static native Logger DailyFileSink.CreateLogger()
    public static native Logger RingBufferSink.CreateLogger()
    public static native Logger RotatingFileSink.CreateLogger()
    public static native Logger ServerConsoleSink.CreateLogger()

改进 APIs

  • 新增 Native Logger.CreateLoggerWith, Logger.CreateLoggerWithEx#24

  • 新增 Native Logger.AddSinkEx#24

    添加 sink 成功后会自动释放参数 sink Handle

  • 新增 Native Logger.GetNameLength (#20)

  • 新增 Logger.ApplyAll 可选 data 参数 (#18) (#20)(感谢 @blueblur0730

    // v1.6.0
    void ApplyAll(LoggerApplyAllCallback callback);
    
    // v1.7.0
    void ApplyAll(LoggerApplyAllCallback callback, any data = 0);
  • 新增 LoggerErrorHandler 回调可选参数(#24

    // v1.6.0
    function void (const char[] msg);
    
    // v1.7.0
    function void (const char[] msg, const char[] name, const char[] file, int line, const char[] func);

Sink

  • 移除多线程 Sink (#21)

  • 移除 MethodMap ClientChatSinkClientConsoleSink (#21)

    对于自定义目标的需求,请使用 CallbackSink

  • 新增 MethodMap ClientChatAllSinkClientConsoleAllSink (#21)

  • 新增 MethodMap CallbackSink (#22) (#23)

  • 新增 MethodMap RingBufferSink (#25)

杂项
  • 新增宏 LOG4SP_GLOBAL_LOGGER_NAME

  • 新增支持 UTF8 编码的 logger 名称和文件路径

  • 新增功能 LOG4SP_NO_EXT

    • 支持输出 Off 级别日志

    • 支持 Logger.LogSrc 和 Logger.LogLoc

  • 修复 Logger.ApplyAll 一处可能发生的内存泄漏

  • 修复堆栈跟踪的日志消息不完整

  • 修复罕见的因底层 Sink 引起的崩溃 (#15) (#16)

  • 优化运行效率(#24

    • Logger.ApplyAll 执行效率(小幅)

    • 记录日志操作执行效率(小幅)

    • 不输出的日志级别的执行效率(显著)

    • 基类 Sink Handle 的执行效率(显著)

  • 优化编译构建脚本 (#17)

    • 编译构建效率

    • 生成的二进制文件大小

    • 迁移专项宏定义和调优参数到构建脚本

    • 移除 "extern/spdlog" 里的所有修改

  • 移动测试用例文件到 testsuit 文件夹

  • 统一项目名称 "Log for SourcePawn"

v1.6.0

29 Dec 02:19
Compare
Choose a tag to compare

Feat

  • Added static factory function Logger.CreateClientChatLogger

  • Added static factory function Logger.CreateClientConsoleLogger

  • Added static function Logger.ApplyAll

    Function: Apply a user defined function on all logger handles.

  • Added console command "sm log4sp list"

    Function: list the names of all current logger handles

  • Added console command "sm log4sp apply_all"

    Function: Apply a command on all loggers.

Fix

  • Fix spelling error in <log4sp_no_ext/common.inc>

  • Fix Logger.ThrowErrorEx does not break sp code on format error

  • Fix Console outputs garbled characters when the function name does not exist

  • Add robustness check for configuration "Log4sp_ThreadPoolThreadCount"

chore

  • Some performance improvements

  • Updated the extension description

  • Updated includes file documentation and layout

  • Added builds on Ubuntu 20.04 and Ubuntu 22.04

This is the last release of 2024.

Happy New Year to you all~


新功能

  • 新增静态工厂方法 Logger.CreateClientChatLogger

  • 新增静态工厂方法 Logger.CreateClientConsoleLogger

  • 新增静态方法 Logger.ApplyAll

    作用:在所有 logger handle 上应用一个用户自定的函数

  • 新增控制台指令 "sm log4sp list"

    作用:列出当前所有 logger handle 的名称

  • 新增控制台指令 "sm log4sp apply_all"

    作用:在所有 logger 上应用一个指令

修复:

  • 修复 <log4sp_no_ext/common.inc> 中的拼写错误

  • 修复 Logger.ThrowErrorEx 在格式错误时,不会中断 sp 代码

  • 修复控制台指令在 function name 不存在时,响应消息出现乱码

  • 增加配置项 "Log4sp_ThreadPoolThreadCount" 的健壮性检查

杂项

  • 一些性能优化

  • 更新拓展的介绍信息

  • 更新 头文件文档和排版

  • 增加 Ubuntu 20.04 和 Ubuntu 22.04 上构建的版本

这是 2024 年的最后一个发行版,预祝各位新年快乐~

v1.5.0

14 Dec 09:34
4287618
Compare
Choose a tag to compare

Changes that are not backwards compatible (may require sp code changes)

Logger

  • Change Logger.DropSink() function return value
    • bool --> void

Sink

  • Remove ***SinkST methodmap and ***SinkMT methodmap, merge into the same methodmap

  • Remove Sink methodmap all logging functions, only keep one Sink.Log()

  • Change RotatingFileSink.CalcFilename() to static function

Others

  • Change handle permissions

    • New: Except for the default Logger, each Logger and Sink can be released by any plugin
    • Old: Can only be released by the creator, other plugins are read-only and cannot be released
  • Change log4sp_empty header file path to log4sp_no_ext

Backward compatible changes

Logger

  • Added method Logger.LogEx() #10

    • Support "unlimited length" formatted log messages
    • Support format errors without interrupting the sp code, but passing the error information to the error handler of the Logger
    • Fixed the formatting overflow bug in SourceMod. See: SM issues
  • Change the name of the Logger's custom error handler

    • Log4spErrorCallback --> LoggerErrorHandler
    • Note! The beta version added a name parameter, but it has been removed in this release
  • Fixed a concurrency safety issue with asynchronous loggers #4

    • Removed deprecation marks for Logger.AddSink() and Logger.DropSink()
  • Fixed Logger.Get() not working as expected #12

  • Fixed Logger.LogAmxTpl() outputting the previous log message when the format is wrong

Sink

  • Added ClientChatSink to support output to the player chat box #11

  • Added BaseFileSink.Truncate() function

  • Added RotatingFileSink.RotateNow() function

  • Changed the player filter name of ClientConsoleSink

    • ClientConsoleSinkFilter --> SinkClientFilter
  • Fixed ClientConsoleSink The output log message is garbled

  • Fixed ClientConsoleSink repeated release filter forward

Common

  • Added global default logger name macro definition: LOG4SP_DEFAULT_LOGGER_NAME

  • Added NameToLogLevel() recognizable log level names

    warn: warning
    error: err
    fatal: critical

Others

  • Enhanced LOG4SP_NO_EXT
    • Use pure sp code to implement LogLevelToName(), LogLevelToShortName(), NameToLogLevel()
    • Optimize the format of log output



不向下兼容(可能需要修改插件代码)的改动

Logger

  • 变更 Logger.DropSink() 函数返回值
    • bool --> void

Sink

  • 移除 ***SinkST methodmap***SinkMT methodmap,合并为同一个 methodmap

  • 移除 Sink methodmap 所有日志输出函数,只保留一个 Sink.Log()

  • 变更 RotatingFileSink.CalcFilename() 为静态函数

其他

  • 变更 handle 权限

    • 新:除了默认 Logger,每个 Logger 和 Sink 都可以被任意的插件释放
    • 旧:只能被创造者释放,其他插件是只读的,无法释放
  • 变更 log4sp_empty 头文件路径为 log4sp_no_ext

向下兼容的改动

Logger

  • 新增方法 Logger.LogEx() #10

    • 支持 "无限长度" 的格式化日志消息
    • 支持格式错误不中断 sp 代码,而是将错误信息传递给 Logger 的错误处理器
    • 修复 SourceMod 中格式化溢出的 BUG。详见:SM issues
  • 变更 Logger 的自定义错误处理器名称

    • Log4spErrorCallback --> LoggerErrorHandler
    • 注意! beta 版新增了 name 参数,但在此正式版已移除
  • 修复异步 Logger 的并发安全问题 #4

    • 已移除 Logger.AddSink()Logger.DropSink() 的过时标记
  • 修复 Logger.Get() 没有按照预期工作 #12

  • 修复 Logger.LogAmxTpl() 格式错误时会输出上一条日志消息

Sink

  • 新增 ClientChatSink ,支持输出到玩家聊天框 #11

  • 新增 BaseFileSink.Truncate() 函数

  • 新增 RotatingFileSink.RotateNow() 函数

  • 变更 ClientConsoleSink 的玩家过滤器名称

    • ClientConsoleSinkFilter --> SinkClientFilter
  • 修复 ClientConsoleSink 输出的日志消息乱码

  • 修复 ClientConsoleSink 重复释放 filter forward

Common

  • 新增全局默认 Logger 名称的宏定义: LOG4SP_DEFAULT_LOGGER_NAME

  • 新增 NameToLogLevel() 可识别的日志级别的名称

    warn: warning
    error: err
    fatal: critical

其他

  • 增强 LOG4SP_NO_EXT

    • 使用纯 SourcePawn 代码实现 LogLevelToName()LogLevelToShortName()NameToLogLevel()
    • 优化日志输出的格式

v1.5.0-beta

09 Dec 11:19
Compare
Choose a tag to compare
v1.5.0-beta Pre-release
Pre-release

New Features

  • Added native Logger.***Ex() that can format unlimited length (#10)

    public native void LogEx(LogLevel lvl, const char[] fmt, any ...);
    public native void LogSrcEx(LogLevel lvl, const char[] fmt, any ...);
    public native void InfoEx(const char[] fmt, any ...);

  • Added output source ClientChatSink (output to player chat box) (#11)

  • Added macro definition for default logger name

    LOG4SP_DEFAULT_LOGGER_NAME

  • Added alias that NameToLogLevel() can recognize

    warn - warning
    error - err
    fatal - critical

Changes

  • Changed the return value of Logger.DropSink()

    New: public native void DropSink(Sink sink);

    Old: public native bool DropSink(Sink sink);

  • Changed Logger's custom error handler

    New: LoggerErrorHandler --> function void (const char[] name, const char[] msg);

    Old: Log4spErrorCallback --> function void (const char[] msg);

  • Changed handle permissions

    New: Except for the default logger, each Logger and Sink created by a plugin can be released by any plugin

    Old: Logger and Sink can only be released by the creator, other plugins can only use, not release

  • Changed (merge) methodmaps of single-threaded Sink and multi-threaded Sink

    Now there is only one methodmap for the single-threaded and multi-threaded versions of each Sink

    To create a multi-threaded Sink, just set multiThread to true in the constructor

  • Remove all log output native except Sink.Log() in the Sink methodmap

  • Changed ClientConsoleSink

    New: SinkClientFilter --> function Action (int client);

    Old: ClientConsoleSinkFilter --> function Action (int client);

  • Changed RotatingFileSink.CalcFilename() to static function

  • Changed log4sp_empty header to log4sp_no_ext

  • Enhanced LOG4SP_NO_EXT

    Implemented pure SourcePawn version of LogLevelToName(), LogLevelToShortName(), NameToLogLevel()

    Optimized log output format

Fixes

  • Fixed concurrency issues in Logger.AddSink(), Logger.DropSink() (deprecated mark removed) (#4)

  • Fixed Logger.Get() not working as expected (#12)

  • Fixed Logger.***AmxTpl() outputting last log message when formatting error

  • Fixed the problem that the formatting width is smaller than the data length, and the padding characters may fill the output buffer

    This BUG originates from SourceMod's Format API (alliedmodders/sourcemod#2221)

    Logger.***Ex() solves this problem by rewriting the format, while Logger.***AmxTpl() still calls the SM Format API internally, so this problem still exists

  • Fixed ClientConsoleSink ClientChatSink repeated release filter forward

  • Fixed ClientConsoleSink ClientChatSink log message garbled


Full change log see: #13 (comment)



新特性

  • 新增可格式化无限长度的 native Logger.***Ex() (#10)

    public native void LogEx(LogLevel lvl, const char[] fmt, any ...);
    public native void LogSrcEx(LogLevel lvl, const char[] fmt, any ...);
    public native void InfoEx(const char[] fmt, any ...);

  • 新增输出源 ClientChatSink(输出到玩家聊天框) (#11)

  • 新增默认 logger 名称的宏定义

    LOG4SP_DEFAULT_LOGGER_NAME

  • 新增 NameToLogLevel() 可识别的别名

    warn - warning
    error - err
    fatal - critical

变更

  • 变更 Logger.DropSink() 的返回值

    新:public native void DropSink(Sink sink);

    旧:public native bool DropSink(Sink sink);

  • 变更 Logger 的自定义错误处理器

    新:LoggerErrorHandler --> function void (const char[] name, const char[] msg);

    旧:Log4spErrorCallback --> function void (const char[] msg);

  • 变更 handle 权限

    新:除了默认 logger,每个由插件创建的 Logger 和 Sink 都可以被任何插件释放

    旧:Logger 和 Sink 只能被创建者释放,其他插件只能使用,不能释放

  • 变更(合并)单线程 Sink 与多线程 Sink 的 methodmap

    现在每种 Sink 的单线程和多线程版都只有一个 methodmap

    创建多线程 Sink,只需在构造函数里将 multiThread 设为 true

  • 移除 Sink methodmap 中除 Sink.Log() 以外的所有日志输出 native

  • 变更 ClientConsoleSink 的玩家过滤器

    新:SinkClientFilter --> function Action (int client);

    旧:ClientConsoleSinkFilter --> function Action (int client);

  • 变更 RotatingFileSink.CalcFilename() 为静态函数

  • 变更 log4sp_empty 头文件为 log4sp_no_ext

  • 增强 LOG4SP_NO_EXT

    实现纯 SourcePawn 版的 LogLevelToName()、LogLevelToShortName()、NameToLogLevel()

    优化日志输出的格式

修复

  • 修复 Logger.AddSink()Logger.DropSink() 的并发问题(已移除过时标记)(#4)

  • 修复 Logger.Get() 没有按照预期工作 (#12)

  • 修复 Logger.***AmxTpl() 格式化错误时会输出上一次日志消息的问题

  • 修复格式化宽度小于数据长度,填充字符可能会填满输出缓冲区的问题

    此 BUG 源于 SourceMod 的 Format API(https://github.com/alliedmodders/sourcemod/issues/2221)

    Logger.***Ex() 通过重写格式化解决了此问题,而 Logger.***AmxTpl() 内部调用的仍是 SM Format API,故仍存在此问题

  • 修复 ClientConsoleSink ClientChatSink 重复释放 filter forward

  • 修复 ClientConsoleSink ClientChatSink 日志消息乱码

详细更新日志:#13 (comment)

v1.4.1

12 Nov 02:26
Compare
Choose a tag to compare

Feature

  • Add release compiled under SourceMod 1.12

Fixed

  • Loading failed on Linux (#6)

  • console command "sm log4sp log ..." causing crash (#8)


特性

  • 新增在 SourceMod 1.12 下编译的发行版

修复

  • 拓展在 Linux 服务器上可能加载失败 (#6)

  • 控制台指令 "sm log4sp log ..." 会导致服务器崩溃 (#8)

v1.4.0

09 Nov 02:31
Compare
Choose a tag to compare

New features

  • Added natives

    • Logger.LogStackTrace()

    • Logger.LogStackTraceAmxTpl()

    • Logger.ThrowError()

    • Logger.ThrowErrorAmxTpl()

  • Added macro definitions

    • LOG4SP_NO_LOG

      This feature is added because some developers do not want to rely on too many external components when releasing new plugins;

      If this macro is defined before the header file is introduced, most natives will be replaced with empty functions, and only a few natives that print logs will be replaced with sourcemod API;

      The compiled plugin will no longer rely on the log4sp extension, and key logs will also be recorded. (Info level and above, recorded by sourcemod API).

Changes

  • These natives are deprecated and are not recommended to be used anymore. And they may be removed in future versions.

    • Logger.AddSink()

    • Logger.DropSink()

      Tips: Use new Logger() instead

    • Removed default Logger configuration from starter config (only thread pool configuration left)

    • Optimized help documentation for console command sm log4sp

Fixes

  • Fixed memory leak when calling these natives

    • Logger.LogSrc()

    • Logger.LogSrcAmxTpl()

    • Sink.LogSrc()

    • Sink.LogSrcAmxTpl()

  • Now sets global client for translation to server default language before formatting log messages


新特性

  • 新增 natives

    • Logger.LogStackTrace()

    • Logger.LogStackTraceAmxTpl()

    • Logger.ThrowError()

    • Logger.ThrowErrorAmxTpl()

  • 新增宏定义

    • LOG4SP_NO_LOG

      考虑到有开发者发布新插件时不希望依赖过多的外部组件而添加了这个功能;

      如果在引入 头文件之前定义这个宏,大部分 natives 将被替换为空函数,仅少部分打印日志的 natives 使用 sourcemod API 替代;

      编译出来的插件就不再依赖 log4sp 拓展,并且关键的日志也会记录。(Info 级别及以上,由 sourcemod API 记录)。

变更

  • 这些 natives 已经过时,不推荐继续使用,并且可能在未来的版本移除

    • Logger.AddSink()

    • Logger.DropSink()

      Tips: 使用 new Logger() 替代

  • 移除了起步配置中默认 Logger 的配置项(目前仅剩线程池配置项)

  • 优化了控制台指令 sm log4sp 的帮助文档

修复

  • 修复了调用这些 natives 时产生的内存泄漏

    • Logger.LogSrc()

    • Logger.LogSrcAmxTpl()

    • Sink.LogSrc()

    • Sink.LogSrcAmxTpl()

  • 现在进行格式化日志消息前,会先将用于辅助翻译的全局客户端设为服务器默认语言

v1.3.2

14 Sep 10:45
Compare
Choose a tag to compare

Chore: Windows releases are available from now on.
Fixed: A minor compilation warning.

v1.3.1

12 Sep 05:21
Compare
Choose a tag to compare

fix: native Logger.ErrorAmxTpl parameter not formatted.

v1.3.0

03 Sep 15:37
Compare
Choose a tag to compare

New feature: support custom configuration

  • thread pool

    • queue size

    • thread count

  • default logger

    • name

    • type (sync or async)

    • log level

    • log message pattern

    • flush level

    • backtrace number

v1.2.2

03 Sep 15:35
Compare
Choose a tag to compare

Performances optimisation: change the default logger to asynchronous