amphp / log
基于Amp、Revolt和Monolog的PHP非阻塞日志记录。
v2.0.0
2023-08-05 18:59 UTC
Requires
- php: >=8.1
- amphp/amp: ^3
- amphp/byte-stream: ^2
- monolog/monolog: ^3|^2|^1.23
- psr/log: ^3|^2|^1
Requires (Dev)
- amphp/file: ^3
- amphp/php-cs-fixer-config: ^2
- amphp/phpunit-util: ^3
- phpunit/phpunit: ^9
- psalm/phar: ^5.6
This package is auto-updated.
Last update: 2024-09-05 21:16:36 UTC
README
AMPHP是一组为PHP设计的基于事件、纤维和并发性的库集合。 amphp/log
为 monolog/monolog
提供了一个非阻塞流处理器。
安装
此包可以作为 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!");