mileschou/monoex

Monolog 扩展

v2.1.1 2023-10-11 02:17 UTC

This package is auto-updated.

Last update: 2024-09-11 04:19:33 UTC


README

tests codecov Codacy Badge Latest Stable Version Total Downloads License

Monolog 扩展。

  • 版本 0.x 支持 PHP 7.1 ~ 8.0 和 Laravel 5.7 ~ 9.0。
  • 版本 2.x 支持 PHP 8.1 和 Laravel 10。

在 Laravel 上使用

此包实现了包发现,以下PSR-17 / PSR-18 驱动必须注册

  • Psr\Http\Client\ClientInterface
  • Psr\Http\Message\RequestFactoryInterface
  • Psr\Http\Message\StreamFactoryInterface

例如,使用laminas/laminas-diactorossymfony/http-client

$app->singleton(RequestFactoryInterface::class, new \Laminas\Diactoros\RequestFactory());
$app->singleton(ResponseFactoryInterface::class, new \Laminas\Diactoros\ResponseFactory());
$app->singleton(StreamFactoryInterface::class, new \Laminas\Diactoros\StreamFactory());

$app->singleton(ClientInterface::class, function($app) {
    return new \Symfony\Component\HttpClient\Psr18Client(
        null,
        $app->make(ResponseFactoryInterface::class),
        $app->make(StreamFactoryInterface::class)
    );
});

最后,可以在 logging.php 配置中使用新的驱动 psr18slack

return [
    'channels' => [
        'stack' => [
            'driver' => 'psr18slack',
            // same as slack driver
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
            'level' => 'critical',
        ],
    ],
];

许可证

MIT 许可证 (MIT)。请参阅许可证文件获取更多信息。