hyperf-aliyun-log/aliyun-sls 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hyperf-aliyun-log/aliyun-sls

Composer 安装命令:

composer require hyperf-aliyun-log/aliyun-sls

包简介

AliYun SLS Log For Hyperf

README 文档

README

AliYun SLS Log For Hyperf

Copyright (c) 2020 尹萌

Fixed by Ken 2021 肯

一 安装

composer require hyperf-aliyun-log/aliyun-sls

二 使用

  1. 生成配置文件
php bin/hyperf.php vendor:publish hyperf-aliyun-log/aliyun-sls
  1. putlog 到阿里云 sls
use Hyperf\Di\Annotation\Inject;
use Ym\AliyunSls\ClientInterface;

/**
* @Inject
* @var ClientInterface
*/
protected $sls;

// 注意不能有空置,如果有空值可以处理为0,否则无法压缩数据产生致命错误。
$logData = ['k1'=>v1,'k2'=>v2,……];
$this->sls->putLogs($logData);
  1. getlog 从阿里云 sls
use Hyperf\Di\Annotation\Inject;
use Ym\AliyunSls\ClientInterface;

/**
* @Inject
* @var ClientInterface
*/
protected $sls;

/**
 *
 * @param string $project
 *            project name
 * @param string $logStore
 *            logstore name
 * @param integer $from
 *            the begin time
 * @param integer $to
 *            the end time
 * @param string $topic
 *            topic name of logs
 * @param string $query
 *            user defined query
 * @param integer $line
 *            query return line number
 * @param integer $offset
 *            the log offset to return
 * @param bool $reverse
 *            if reverse is set to true, the query will return the latest logs first
 */
 
$response = $this->sls->getLogs($project, $logstore, $from, $to, $topic, $query, $line, $offset, $reverse);
if ($response->getCount()[0] > 0) {
    foreach($response->getLogs() as $log){
        $datas[] = $log->getContents();
    }
    print_r($datas);
}

统计信息

  • 总下载量: 66
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固