comphp/logging-monolog
Composer 安装命令:
composer require comphp/logging-monolog
包简介
Logging Driver for CommonPHP which wraps the Monolog library for Runtime compliance
README 文档
README
Logging driver for CommonPHP that wraps Monolog for configurable PSR-3 logging.
Requirements
- PHP
^8.5 comphp/logging:^0.3monolog/monolog
Installation
Once this package is available through your Composer repositories, install it with:
composer require comphp/logging-monolog
Usage
<?php use CommonPHP\Drivers\Logging\Monolog\MonologDriverOptions; use CommonPHP\Drivers\Logging\Monolog\MonologHandlerFactory; use CommonPHP\Drivers\Logging\Monolog\MonologLogDriver; use CommonPHP\Logging\LogManager; $handlers = new MonologHandlerFactory(); $logger = new LogManager(new MonologLogDriver(options: new MonologDriverOptions( channel: 'app', handlers: [ $handlers->file(__DIR__ . '/var/app.log'), ], ))); $logger->info('User {user} logged in.', ['user' => 'ada']);
Driver Notes
This driver is intended to let CommonPHP Logging use Monolog handlers, processors, formatters, and channels without making the core logging package depend directly on Monolog.
Applications may use this driver when they need production-ready logging targets, rotation, formatting, or integrations that Monolog already supports.
MonologLoggerFactory, MonologHandlerFactory, MonologFormatterFactory, and MonologProcessorFactory provide small helpers for common setup while still allowing applications to pass native Monolog objects directly.
Error Handling
Logger setup, handler, formatting, write, and configuration failures should throw CommonPHP logging driver exceptions when logging cannot be completed or configured safely.
Documentation
License
MIT. See LICENSE.md.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-20