定制 sympress/monolog-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sympress/monolog-bundle

Composer 安装命令:

composer require sympress/monolog-bundle

包简介

Monolog integration bundle for the WordPress kernel.

README 文档

README

Monolog integration bundle for SymPress WordPress kernel applications.

The package provides a Composer-powered WordPress MU plugin that registers a Monolog logger, channel loggers, configurable handlers, processors, and WordPress-specific logging hooks through the SymPress kernel service container.

Installation

composer require sympress/monolog-bundle

The package requires PHP 8.5, sympress/kernel, monolog/monolog, and psr/log.

Features

  • Default PSR-3 logger service exposed as logger and Psr\Log\LoggerInterface
  • Channel logger support through monolog.logger tags and Monolog attributes
  • Configurable handlers for stream, rotating file, fingers crossed, grouped, filtered, console, mail, syslog, socket, Slack webhook, and related Monolog handler types
  • Handler-to-channel routing with inclusive and exclusive channel rules
  • Tagged processor registration with handler or channel targeting
  • WordPress runtime context processor
  • Kernel throwable, WordPress database, and HTTP API logging hooks
  • Profiler bridge that forwards buffered Monolog records to SymPress Profiler

Usage

When the SymPress kernel discovers the package, it registers SymPress\MonologBundle\MonologBundle and loads monolog-bundle/monolog-bundle.php as the MU plugin entry point.

<?php

use Psr\Log\LoggerInterface;

final readonly class ImportOrders
{
    public function __construct(
        private LoggerInterface $logger,
    ) {
    }

    public function run(): void
    {
        $this->logger->info('Import started.');
    }
}

Configuration

The package ships with a default stream handler and a profiler buffer handler. Project configuration can override handlers and channels through the Monolog extension.

monolog:
    channels:
        - security
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: nested
        nested:
            type: stream
            path: '%kernel.logs_dir%/%kernel.environment%.log'
            level: debug
            nested: true
        security_file:
            type: stream
            path: '%kernel.logs_dir%/security.log'
            channels: [security]

Services can request channel-specific loggers by using Monolog's WithMonologChannel attribute or the monolog.logger service tag.

Development

composer install
composer test
composer cs:analyze
composer cs

Use composer cs:fix to apply automatic style fixes.

License

This package is licensed under GPL-2.0-or-later.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-06-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固