8

Swoole v4.8.1 版本发布,支持忽略指定错误码的日志

 2 years ago
source link: https://segmentfault.com/a/1190000040885293
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

v4.8.1 版本主要优化了 admin server 的代码,没有向下不兼容改动。

支持忽略指定的错误码日志

在此版本中增加了可以忽略指定的错误码所对应的错误日志,举个例子:

const LOG_FILE = __DIR__ . '/log';
if (is_file(LOG_FILE)) {
    unlink(LOG_FILE);
}

const ERRNO_1 = 888888;
const ERRNO_2 = 999999;

swoole_async_set(['log_file' => LOG_FILE]);
swoole_error_log(SWOOLE_LOG_NOTICE, 'swoole_error_log msg');
swoole_error_log_ex(SWOOLE_LOG_NOTICE, ERRNO_1, 'swoole_error_log_ex msg');

// 忽略错误码为ERRNO_2的日志
swoole_ignore_error(ERRNO_2);
swoole_error_log_ex(SWOOLE_LOG_NOTICE, ERRNO_2, 'swoole_error_log_ex ERRNO_2 msg');

echo file_get_contents(LOG_FILE);

忽略了错误码为ERRNO_2的日志,所以查看错误日志中没有swoole_error_log_ex ERRNO_2 msg的信息。

[2021-10-28 10:34:01 @23580.0]  NOTICE  swoole_error_log msg
[2021-10-28 10:34:01 @23580.0]  NOTICE  zif_swoole_error_log_ex() (ERRNO 888888): swoole_error_log_ex msg

同时也可以使用swoole_error_log_ex函数写入指定错误等级、错误码的日志到日志文件中。

Admin Server

此版本中优化了大量的 admin_server 的代码:

  • 迁移 ext-swoole_plus 中的 admin api 到 ext-swoole,可以使用 Swoole Dashboard 的全部功能
  • 支持了并发请求多个目标和并发请求多个 API,详情可以查看 RFC #78
  • 新增 get_composer_packages 命令,可以查看项目中的 composer 依赖信息
  • 支持获取某个类中的方法信息
  • 支持获取某个interface的信息

可以更新 swoole 版本后,前往 Swoole Dashboard 进行体验。

下面是完整的更新日志:

新增 API

  • 新增 swoole_error_log_ex()swoole_ignore_error() 函数 (#4440) (@matyhtf)
  • 迁移 ext-swoole_plus 中的 admin api 到 ext-swoole (#4441) (@matyhtf)
  • admin server 新增 get_composer_packages 命令 (swoole/library@07763f46) (swoole/library@8805dc05) (swoole/library@175f1797) (@sy-records) (@yunbaoi)
  • 增加了写操作的 POST 方法请求限制 (swoole/library@ac16927c) (@yunbaoi)
  • admin server 支持获取类方法信息 (swoole/library@690a1952) (@djw1028769140) (@sy-records)
  • 优化 admin server 代码 (swoole/library#128) (swoole/library#131) (@sy-records)
  • admin server 支持并发请求多个目标和并发请求多个 API (swoole/library#124) (@sy-records)
  • admin server 支持获取接口信息 (swoole/library#130) (@sy-records)
  • SWOOLE_HOOK_CURL 支持 CURLOPT_HTTPPROXYTUNNEL (swoole/library#126) (@sy-records)
  • join 方法禁止并发调用同一个协程 (#4442) (@matyhtf)
  • 修复 Table 原子锁意外释放的问题 (#4446) (@Txhua) (@matyhtf)
  • 修复丢失的 helper options (swoole/library#123) (@sy-records)
  • 修复 get_static_property_value 命令参数错误 (swoole/library#129) (@sy-records)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK