amphp/log

基于Amp、Revolt和Monolog的PHP非阻塞日志记录。

维护者

详细信息

github.com/amphp/log

主页

源代码

问题

资助包维护!
amphp

v2.0.0 2023-08-05 18:59 UTC

This package is auto-updated.

Last update: 2024-09-05 21:16:36 UTC


README

AMPHP是一组为PHP设计的基于事件、纤维和并发性的库集合。 amphp/logmonolog/monolog 提供了一个非阻塞流处理器。

Release License

安装

此包可以作为 Composer 依赖项安装。

composer require amphp/log

用法

<?php

use Amp\ByteStream;
use Amp\Log\ConsoleFormatter;
use Amp\Log\StreamHandler;
use Monolog\Logger;

require dirname(__DIR__) . '/vendor/autoload.php';

// You can also log to a file using amphp/file:
// $handler = new StreamHandler(File\openFile(__DIR__ . '/example.log', 'w'));

// Here we'll log to the standard output stream of the current process:
$handler = new StreamHandler(ByteStream\getStdout());
$handler->setFormatter(new ConsoleFormatter);

$logger = new Logger('main');
$logger->pushHandler($handler);

$logger->debug("Hello, world!");
$logger->info("Hello, world!");
$logger->notice("Hello, world!");
$logger->error("Hello, world!");
$logger->alert("Hello, world!");