Skip to content

Conversation

@huangdijia
Copy link
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 huangdijia changed the base branch from master to 3.2 October 16, 2025 01:03
@huangdijia huangdijia added this to the v3.2 milestone Oct 16, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@limingxinleo
Copy link
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 huangdijia force-pushed the logger-config-optimizing branch from 67c75a2 to 73032b9 Compare November 3, 2025 11:22
@huangdijia
Copy link
Member Author

兼容老版 logger 结构

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

调整好了

@limingxinleo limingxinleo merged commit 2ba8705 into hyperf:3.2 Nov 3, 2025
70 of 76 checks passed
@huangdijia huangdijia deleted the logger-config-optimizing branch November 3, 2025 14:22
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.

2 participants