wpjscc / reactphp-log
基于 reactphp 和 Monolog 的 PHP 非阻塞日志记录。
v1.0.0
2023-11-07 03:01 UTC
Requires
- php: >=8.1
- monolog/monolog: ^3|^2|^1.23
- psr/log: ^3|^2|^1
- react/stream: ^1.3
- wpjscc/filesystem: ^0.2@dev
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-09-07 05:10:32 UTC
README
reactphp 是一个为 PHP 设计的基于事件、纤程和并发性的库集合。 wpjscc/reactphp-log
为 monolog/monolog
提供了一个非阻塞的流处理程序。
安装
此软件包可以作为 Composer 依赖项安装。
composer require wpjscc/reactphp-log -vvv
使用方法
<?php use React\Stream; use Wpjscc\Log\ConsoleFormatter; use Wpjscc\Log\StreamHandler; use Wpjscc\Log\FileWriteStream; use Monolog\Logger; require dirname(__DIR__) . '/vendor/autoload.php'; // $handler = new StreamHandler(new FileWriteStream(__DIR__ . '/example.log')); // Here we'll log to the standard output stream of the current process: $handler = new StreamHandler(new Stream\WritableResourceStream(STDOUT)); $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!");