amphp / log
Non-blocking logging for PHP based on Amp, Revolt, and Monolog.
Fund package maintenance!
amphp
Installs: 1 880 048
Dependents: 90
Suggesters: 1
Security: 0
Stars: 35
Watchers: 9
Forks: 6
Open Issues: 1
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-12-05 21:50:37 UTC
README
AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind.
amphp/log
provides a non-blocking stream handler for monolog/monolog
.
Installation
This package can be installed as a Composer dependency.
composer require amphp/log
Usage
<?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!");