定制 abryb/console-handler 二次开发

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

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

abryb/console-handler

Composer 安装命令:

composer require abryb/console-handler

包简介

Monolog console handler with output sections for symfony. Progress bar based on logs.

README 文档

README

Installation

Install package
composer require abryb/console-handler
Register service
# config/services.yaml
Abryb\ConsoleHandler\ConsoleHandler:
    decorates: monolog.handler.console
    class: Abryb\ConsoleHandler\ConsoleHandler
Add progress bar based on application logs
<?php

namespace App\Command;


use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Abryb\ConsoleHandler\ConsoleHandler;
use Abryb\ConsoleHandler\ConsoleHandlerAwareCommand;
use Abryb\ConsoleHandler\Section\Log\RotateLogSection;
use Abryb\ConsoleHandler\Section\ProgressBar\RegexProgressBarSection;

class MyCommand extends Command implements ConsoleHandlerAwareCommand
{
    private $logger;
    
    public function __construct(LoggerInterface $logger)
    {
        $this->logger = $logger;
        parent::__construct();
    }

    public function configureConsoleHandler(ConsoleHandler $consoleHandler)
    {
        $consoleHandler->setSections([
            new RotateLogSection(), 
            new RegexProgressBarSection(
                '#My loop with (?<maxCount>\\d+) items#', // start regex
                '#Loop item \d+', // advance regex
                '#Loop finished#', // finish regex
                'Foo bar' // name of progress bar
            ),
        ]);        
    }
    
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Do my very long job with loop ...
        $this->logger->debug('My loop with 1000 items');
        for ($i = 0; $i < 1000; $i++) {
            usleep(500);
            $this->logger->debug("Loop item {$i}");
        }
        $this->logger->debug("Loop finished");
        
        return 0;
    }    
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固