FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

refactor(logger): optimize logger configuration structure by huangdijia · Pull Request #7563 · hyperf/hyperf · GitHub

/ hyperf Public

refactor(logger): optimize logger configuration structure - #7563

Merged
limingxinleo merged 14 commits into
hyperf:3.2from
huangdijia:logger-config-optimizing
Nov 3, 2025
Merged

refactor(logger): optimize logger configuration structure#7563
limingxinleo merged 14 commits into
hyperf:3.2from
huangdijia:logger-config-optimizing

Conversation

Copy link
Copy Markdown
Member

Summary

This PR refactors the logger configuration structure to use a channel-based approach similar to Laravel's logging system, providing better clarity and flexibility.

Changes

  • Configuration Structure: Restructured from group-based to channel-based approach
  • Default Channel: Added support for configuring default channel via LOG_CHANNEL environment variable
  • Predefined Channels: Added multiple ready-to-use channels:
    • stack: Combines multiple channels (configurable via LOG_STACK env var)
    • single: Single log file
    • daily: Rotating daily log files
    • stderr: Output to stderr
    • syslog: System log handler
    • null: Null handler for disabling logs
  • API Changes: Updated LoggerFactory methods to use channel parameter instead of group
  • Type Hints: Improved type hints throughout the codebase
  • Tests: Updated test suite to reflect the new channel-based approach

Test Plan

  • All existing tests pass with the new configuration structure
  • Updated tests to use the new channel parameter
  • Verified backward compatibility with callable configurations

Backward Compatibility

The changes maintain backward compatibility with existing configurations while providing a more intuitive structure for new implementations.

huangdijia changed the base branch from master to 3.2 October 16, 2025 01:03
huangdijia added this to the v3.2 milestone Oct 16, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull Request Overview

This PR refactors the logger configuration from a flat group-based structure to a more organized channel-based approach inspired by Laravel's logging system. The changes introduce a default channel concept and provide multiple predefined channel configurations for common logging scenarios.

Key Changes:

  • Introduced channel-based configuration structure with default and channels keys
  • Updated LoggerFactory API to use channel parameter instead of group
  • Added predefined channel configurations (stack, single, daily, stderr, syslog, null)

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/logger/src/LoggerFactory.php Updated factory methods to use channel-based lookups and improved type hints
src/logger/publish/logger.php Restructured configuration to channel-based format with multiple predefined channels
src/logger/tests/LoggerFactoryTest.php Updated test configuration structure and parameter names to reflect channel-based approach

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/logger/publish/logger.php Outdated

Copy link
Copy Markdown
Member

兼容老版 logger 结构

default 为 string 使用新版,
default 不是 string 使用老版结构。

- Restructured logger configuration to use channel-based approach similar to Laravel
- Changed configuration structure from group-based to channel-based for better clarity
- Added multiple predefined channels: stack, single, daily, stderr, syslog, and null
- Updated LoggerFactory to use 'channel' parameter instead of 'group' parameter
- Added support for default channel configuration via LOG_CHANNEL environment variable
- Added support for stack channel configuration via LOG_STACK environment variable
- Improved type hints in LoggerFactory methods
- Updated tests to reflect the new channel-based approach
- Maintained backward compatibility with existing configurations
huangdijia force-pushed the logger-config-optimizing branch from 67c75a2 to 73032b9 Compare November 3, 2025 11:22

Copy link
Copy Markdown
Member Author

兼容老版 logger 结构

default 为 string 使用新版, default 不是 string 使用老版结构。

调整好了

Comment thread src/logger/src/LoggerFactory.php Outdated
limingxinleo merged commit 2ba8705 into hyperf:3.2 Nov 3, 2025
70 of 76 checks passed
huangdijia deleted the logger-config-optimizing branch November 3, 2025 14:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL