Download the PHP package sllhsmile/hyperf-log without Composer

On this page you can find all versions of the php package sllhsmile/hyperf-log. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hyperf-log

Hyperf Log

PHP Hyperf

面向 Hyperf 3 的结构化日志与请求链路追踪包。它统一采集 HTTP API、数据库、Redis 和 Guzzle 调用日志,并在同一协程链路中复用 request ID。

特性

能力 说明
API 日志 记录 HTTP 请求与响应生命周期数据。
数据库日志 记录 SQL、耗时和执行结果摘要。
Redis 日志 记录 Redis 命令及其执行信息。
Guzzle 日志 自动注入链路 Header、默认超时,并记录 SDK 调用。
协程链路追踪 HTTP、CLI 与手动初始化的 RPC/后台协程共享 request ID。
按 channel 开关 每类采集器可独立启用,避免安装后产生额外日志。

要求

安装

Packagist

Packagist 注册完成后:

GitHub 仓库

尚未注册 Packagist 时,在宿主项目的 composer.json 中加入:

然后安装:

发布链路配置:

Hyperf 会通过 ConfigProvider 自动注册本包的 Listener、Aspect 和 HTTP Middleware。

快速配置

本包不会覆盖宿主项目的 config/autoload/logger.php。在 logger.channels 中添加所需 channel;下例复用 default 的 handler 与 formatter,因此所有结构化日志均写入同一个 file.log

CustomizeJsonFormatter 输出单行 JSON。采集器日志会将 sdklogdblog 等记录类型写入 message_type,并将其 context 平铺到顶层;普通日志(没有 context)使用 {app_name}_log 作为 message_type,原文保留在 messagedatetimemessage_typerequest_idcoroutine_id 是保留字段,不会被 context 覆盖。

宿主应用可按自身部署方式设置默认文件 handler:

Channel 采集内容 默认建议
apilog HTTP API 请求与响应 按需启用
dblog 数据库查询 response_enabled=false
redislog Redis 命令 按需启用
sdklog Guzzle 请求与响应 response_enabled=false

链路追踪

发布后的 config/autoload/trace_log.php 控制 request ID 与 Guzzle 默认行为:

HTTP 请求和 CLI 命令会自动建立 trace:入站 request_id 缺失时生成 UUID v7,写入请求、 协程 Context 和 HTTP 响应 Header;Guzzle 与异步日志子协程会继承同一个 ID。宿主项目可继续 调用 getRequestId(),它会委托给本包的 RequestContext

注意事项

本地开发

推荐将包以独立 Git 仓库放在业务项目同级目录:

宿主项目使用 Composer path repository 软链接本地包:

执行一次更新后,vendor/sllhsmile/hyperf-log 会软链接到本地目录;后续修改包代码可立即在宿主项目中调试:

测试与发布

在包仓库目录执行:

发布前确认测试通过后:

License

MIT. See LICENSE.


All versions of hyperf-log with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
guzzlehttp/guzzle Version ^7.0
hyperf/command Version ^3.2
hyperf/context Version ^3.2
hyperf/coroutine Version ^3.2
hyperf/database Version ^3.2
hyperf/di Version ^3.2
hyperf/event Version ^3.2
hyperf/guzzle Version ^3.2
hyperf/http-server Version ^3.2
hyperf/logger Version ^3.2
hyperf/redis Version ^3.2
ramsey/uuid Version ^4.7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sllhsmile/hyperf-log contains the following files

Loading the files please wait ...