espressobyte/reactphp-monolog

A simple PSR file logger for react php forked from https://github.com/sunvalley-technologies/react-php-file-logger

1.0 2021-12-20 19:01 UTC

This package is auto-updated.

Last update: 2024-11-21 13:18:36 UTC


README

tests Latest Stable Version Total Downloads Latest Unstable Version License

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.