trash-panda/progress-bar-log 问题修复 & 功能扩展

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

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

trash-panda/progress-bar-log

最新稳定版本:1.5

Composer 安装命令:

composer require trash-panda/progress-bar-log

包简介

Component to display a progress bar and last X logs at the same time

README 文档

README

Display a progress bar and a portion of a log at the same time on the CLI!

Preview

Click the image above to see it in action.

Installation

$ composer require trash-panda/progress-bar-log

Use cases

Originally I wanted this for long running import/export work. Being able to see a subset of the most recent log entries and also still see the progress and memory usage without scrolling the terminal. I figured it might be useful for some other people too.

Usage

<?php

use Psr\Log\LogLevel;
use TrashPanda\ProgressBarLog\ProgressBarLog;

require_once __DIR__ . '/vendor/autoload.php';

//The first parameter is the number of log lines to be displayed. The newest entries will be displayed - like a tail.
//The second parameter is the maximum number of steps for the progress bar
$progressLog = new ProgressBarLog(6, 10);
$progressLog->start();

//advance the progress bar by one
$progressLog->advance();

//Add a log line - the first parameter is a psr/log severity constant
//you can pass whatever you want there - but if it is a psr/log constant then the severity is colored accordingly
$progressLog->addLog(LogLevel::CRITICAL, 'Some mission critical error');

See example.php for a working script:

git clone git@github.com:AydinHassan/progress-bar-log.git
cd progress-bar-log
php example.php

Customising the progress bar

The underlying progress bar is an instance of \Symfony\Component\Console\Helper\ProgressBar.

You can modify the settings of the progress bar by getting access to the instance via getProgressBar():

<?php

use TrashPanda\ProgressBarLog\ProgressBarLog;

require_once __DIR__ . '/vendor/autoload.php';

$progressLog = new ProgressBarLog(6, 10);
$progressLog->getProgressBar()->setFormat('normal');
$progressLog->getProgressBar()->setBarWidth(50);
$progressLog->start();

Running unit tests

$ composer test

统计信息

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

GitHub 信息

  • Stars: 41
  • Watchers: 4
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-23