lezhnev74/monolog-async-handler

通过给定闭包发送monolog通知

1.0 2016-01-30 13:30 UTC

This package is auto-updated.

Last update: 2024-08-29 04:00:35 UTC


README

Packagist Build Status Total Downloads

用于通过闭包处理日志写入的monolog处理器。在闭包内部,您可以设置推送队列。

示例用法

use lezhnev74\Monolog\Handler\ClosureHandler;
use Monolog\Logger;

$handler = new ClosureHandler(function ($record) {
    // put your data to queue
    // or any other logic goes here that detaches the logging from life circle
    
    /* 
    the $record contains:
    
    [
        "message"    => "the message goes here",
        "context"    => ["platform" => "ios"], // context
        "level"      => 200,
        "level_name" => "INFO",
        "channel"    => "local",
        "datetime"   => "",
        "extra"      => [],
        "formatted"  => "[2016-01-30 15:41:37] local.INFO: FORMATTED MESSAGE GOES HERE []\n",
    ]
    */
});
$monolog = new Logger('async_logger');
$monolog->pushHandler($handler);

安装

composer require lezhnev74/monolog-async-handler