hongjianghuang/aliyun-log-php-sdk

此包最新版本(v1.1)没有提供许可证信息。

PHP日志服务SDK,用于向阿里云日志服务(www.aliyun.com/product/sls)设置/获取日志数据。

v1.1 2020-04-26 11:04 UTC

This package is auto-updated.

Last update: 2024-09-26 21:07:07 UTC


README

API版本

0.6.1

SDK发布时间

2018-02-18

简介

PHP日志服务SDK,用于向阿里云日志服务(www.aliyun.com/product/sls)设置/获取日志数据。

API参考:中文 英文

使用composer

composer require hongjianghuang/aliyun-log-php-sdk

示例

$log_item = new \Aliyun_Log_Models_LogItem();
$log_item->setTime(time());
$log_item->setContents($contents);

$endpoint = '';
$access_key_id = '';
$access_key = '';
$project = '';
$logstore = ''
$topic = 'test';
$logitems = [
    $log_item,
];

$client = new \Aliyun_Log_Client($endpoint, $access_key_id, $access_key);
$request = new \Aliyun_Log_Models_PutLogsRequest($project, $logstore, $topic, $source, $logitems);
$response = @$client->putLogs($request);
if (200 != array_get($response->getAllHeaders(), '_info.http_code')) {
    throw new \Exception('Request aliyun error');
}

摘要

  1. 请求-请求风格的RESTful API接口
  2. 使用协议缓冲区发送数据
  3. 发送到服务器时可以压缩数据
  4. 如果发生任何错误,将抛出Aliyun_Log_Exception异常
  5. 引入简单的日志记录器,以不同级别轻松提交日志
  6. 创建本地日志缓存,以单个HTTP POST提交多个日志。

环境要求

  1. PHP 7.1.7及以后版本:主分支
  2. PHP 5.2+:v1.0分支