cleatsquad/magento2-logstream 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

cleatsquad/magento2-logstream

Composer 安装命令:

composer require cleatsquad/magento2-logstream

包简介

A Magento 2 module to redirect all logs to StdOut, ideal for dockerized environments.

README 文档

README

A Magento 2 module that redirects all Magento logs to StdOut, making it ideal for Docker and containerized environments. This enables seamless log aggregation into external systems (ELK, Datadog, CloudWatch, etc.) without managing Magento-specific log files.

Badges

Packagist Downloads Packagist Version Packagist License Magento 2.4.6 and above PHP 8.1+

✨ Features

  • 🐳 Docker-ready: Logs to StdOut for seamless container integration.
  • 📊 External Log Aggregation: Works with ELK, Datadog, CloudWatch, Splunk, etc.
  • ⚙️ Configurable Log Levels: Set log level (DEBUG, INFO, WARNING, ERROR, etc.) from admin panel.
  • 🛡️ Clean DI Override: Uses Magento dependency injection, no core hacks.
  • 🎯 Zero Configuration: Works out of the box after installation.
  • 🔄 Real-time Logs: Immediate log output without file I/O delays.
  • 🧩 Monolog Integration: Built on Monolog's StreamHandler.

📦 Installation

You can install this module using Composer (recommended) or manually.

🔹 1. Install via Composer (recommended)

  1. Download the package

    composer require cleatsquad/magento2-logstream
  2. Enable the module

    bin/magento module:enable CleatSquad_LogStream
    bin/magento setup:upgrade

🔹 2. Manual Installation (app/code)

  1. Copy the module to your Magento installation

    app/code/CleatSquad/LogStream/
    
  2. Enable the module

    bin/magento module:enable CleatSquad_LogStream
    bin/magento setup:upgrade

🚀 Usage

Once installed, the module will automatically redirect all Magento logs to StdOut without any additional configuration.

Viewing Logs in Docker

docker logs -f <container_name>

Example Log Output

[2024-01-15 10:30:45] main.INFO: User login successful {"username":"admin"} []
[2024-01-15 10:30:46] main.WARNING: Cache miss for product 123 [] []

⚙️ Configuration

To configure the log level for the CleatSquad Magento2 LogStream module, follow these steps in the Magento admin interface:

Setting the Log Level

  1. Navigate to Stores > Configuration in the admin panel sidebar.
  2. Under the General section, find and open the Logging group.
  3. Select the desired log level from the Log Level dropdown menu.

Available Log Levels

Level Value Description
DEBUG 100 Detailed debug information
INFO 200 Interesting events (default)
NOTICE 250 Normal but significant events
WARNING 300 Exceptional occurrences that are not errors
ERROR 400 Runtime errors
CRITICAL 500 Critical conditions
ALERT 550 Action must be taken immediately
EMERGENCY 600 System is unusable

Changes will take effect immediately after saving the configuration.

🔧 Technical Details

Architecture

This module works by:

  1. Overriding Monolog's handler: Adds a custom StdoutHandler to Magento's logger via DI.
  2. Streaming to php://stdout: All log messages are written directly to standard output.
  3. Respecting log levels: Only logs at or above the configured level are output.

DI Configuration

<type name="Magento\Framework\Logger\Monolog">
    <arguments>
        <argument name="handlers" xsi:type="array">
            <item name="stdout" xsi:type="object">CleatSquad\LogStream\Logger\StdoutHandler</item>
        </argument>
    </arguments>
</type>

🔄 Upgrading

To upgrade the module to the latest version, run:

composer update cleatsquad/magento2-logstream
bin/magento setup:upgrade

📋 Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

🔗 Follow

For the latest updates and new features, follow our GitHub repository: cleatsquad/magento2-logstream.

🤝 Contributing

Contributions to CleatSquad_LogStream are always welcome. You can contribute in different ways:

  1. Report Issues: Report bugs and suggest new features.
  2. Fix Bugs: Submit pull requests with bug fixes.
  3. Add Features: Develop new features and submit them as pull requests.
  4. Improve Documentation: Help new users by improving or translating the documentation.

Issues and pull requests are welcome.

GitHub: https://github.com/CleatSquad/magento2-logstream

💬 Support

If you need help or have a question, you can:

👤 Authors

  • Mohamed EL Mrabet - Initial work - mimou78

See also the list of contributors who participated in this project.

📜 License

This project is licensed under the MIT License - see the LICENSE.md file for details.

🙏 Acknowledgments

This module is powered by the excellent Monolog library:

➡️ https://github.com/Seldaek/monolog

  • Magento Community
  • Anyone who contributes to the open-source community

© 2024 - CleatSquad (https://cleatsquad.dev)

cleatsquad/magento2-logstream 适用场景与选型建议

cleatsquad/magento2-logstream 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 04 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 cleatsquad/magento2-logstream 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cleatsquad/magento2-logstream 我们能提供哪些服务?
定制开发 / 二次开发

基于 cleatsquad/magento2-logstream 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-12