espressobyte / reactphp-monolog
A simple PSR file logger for react php forked from https://github.com/sunvalley-technologies/react-php-file-logger
Installs: 2 607
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.3 || ^7.4 || ^8.0
- monolog/monolog: ^2 || ^1.23
- psr/log: ^1.1
- react/event-loop: ^1.0 || ^0.5 || ^0.4 || ^0.3.5
- react/promise: ^2.3 || ^1.2.1
- react/promise-stream: ^1.1
- react/stream: ^1.0 || ^0.7.6
Requires (Dev)
- phpunit/phpunit: ^9.0 || ^9.0
This package is auto-updated.
Last update: 2024-11-21 13:18:36 UTC
README
React PHP File Logger
A PSR non-blocking file logger for react php. Uses monolog and provides non blocking monolog handlers.
Installing
composer require espressobyte/reactphp-monolog
Usage
Convenient loggers that create a quick monolog logger available as FileLogger
, RotatingFileLogger
and StdIOLogger
.
These loggers are just a quick short-cut to use the non blocking handlers specified below.
Monolog/StreamHandler
<?php use Monolog\Logger; use React\Stream\WritableResourceStream; use EspressoByte\LoopUtil\FileLogger\Monolog\StreamHandler; $logger = new Logger('name'); $loop = \React\EventLoop\Factory::create(); $logger->pushHandler(new StreamHandler(new WritableResourceStream(STDOUT, $loop))); $logger->info('Message!!!'); $loop->run();
Monolog/StdIOHandler
<?php use Monolog\Logger; use EspressoByte\LoopUtil\FileLogger\Monolog\StdIOHandler; $logger = new Logger('name'); $loop = \React\EventLoop\Factory::create(); $logger->pushHandler(new StdIOHandler($loop)); $logger->info('Message!!!'); $loop->run();
Monolog/FileHandler
<?php use Monolog\Logger; use EspressoByte\LoopUtil\FileLogger\Monolog\FileHandler; $logger = new Logger('name'); $loop = \React\EventLoop\Factory::create(); $logFile = __DIR__ . '/test.log'; // expect log file like test-1999-12-31.log $logger->pushHandler(new FileHandler($loop, $logFile)); $logger->info('Message!!!'); $loop->run();
Testing
./vendor/bin/phpunit
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
If you discover any security related issues, please email mtajulasri@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.