定制 infrangible/m2-log 二次开发

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

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

infrangible/m2-log

最新稳定版本:2.0.0

Composer 安装命令:

composer require infrangible/m2-log

包简介

Infrangible Magento 2 Log Wrapper

关键字:

README 文档

README

Introduction

This module was written to enable the possibility of using multiple loggers to log a record into several log files.

If you simply install this module nothing will change because the Magento default logger will be added as first logger. You can add more loggers using a plugin as described.

Usage

Code

The following example is based on a feature module using this base module.

First you need to add a plugin definition in the di.xml of your module.

<type name="Infrangible\Log\Logger\Wrapper">
    <plugin name="module-plugin" type="Infrangible\Module\Plugin\Logging" sortOrder="10" disabled="false"/>
</type>

In this plugin you can add as many additional loggers as you like. In this case four more loggers are added. The loggers itself are included via dependency injection of Magento. Each logger has to implement the Interface LoggerInterface.

<?php

namespace Infrangible\Module\Plugin;

use Infrangible\Module\Logger\Monolog\ErrorLog;
use Infrangible\Module\Logger\Monolog\Log;
use Infrangible\Module\Logger\Monolog\SuccessLog;
use Infrangible\Log\Logger\Wrapper;

/**
 * @author Andreas Knollmann
 */
class Logging
{
    /** @var Log */
    private $moduleLog;

    /** @var ErrorLog */
    private $moduleErrorLog;

    /** @var SuccessLog */
    private $moduleSuccessLog;

    /**
     * @param Log        $moduleLog
     * @param ErrorLog   $moduleErrorLog
     * @param SuccessLog $moduleSuccessLog
     */
    public function __construct(Log $moduleLog, ErrorLog $moduleErrorLog, SuccessLog $moduleSuccessLog)
    {
        $this->moduleLog = $moduleLog;
        $this->moduleErrorLog = $moduleErrorLog;
        $this->moduleSuccessLog = $moduleSuccessLog;
    }

    /**
     * @param Wrapper $wrapper
     */
    public function afterInitialize(Wrapper $wrapper)
    {
        $wrapper->addLoggers([$this->moduleLog, $this->moduleErrorLog, $this->moduleSuccessLog]);
    }
}

License

Infran Log is licensed under the MIT License - see the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固