大圣/monolog-httpapi

Monolog 的处理器,将消息发送到外部 API

v2.0.4 2022-05-19 13:59 UTC

This package is auto-updated.

Last update: 2024-09-19 19:48:08 UTC


README

php monolog 的 HTTP API 处理器,允许您将消息记录到您选择的任何外部 API。

安装

使用 composer 安装

composer require sakydev/monolog-httpapi  

用法

待办事项

示例

现在简单使用它如下

require 'vendor/autoload.php';
use Monolog\Logger;
use sakydev\HttpApiHandler\HttpApiHandler;
$log = new Logger('HttpApiHandler');
$channel = 'default-channel';
$headers = ['Content-Type: application/json'];
$log->pushHandler(new HttpApiHandler('http://url-here.com', $channel, $headers));


$log->notice('hello world !');
$log->info('hello world !');
$log->debug('hello world !');
$log->warning('hello world !');
$log->critical('hello world !');
$log->alert('hello world !');
$log->emergency('hello world !');
$log->error('hello world !');


/**
* Optionally you can pass second paramater such as a object
**/
$log->info('user just logged in !',['user'=>$user]);

许可

此工具受 MIT 许可证保护,因此请随意将其分叉并使其比现在更好!