2017 © Pedro Peláez
 

library progress-bar-log

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

image

trash-panda/progress-bar-log

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

  • Thursday, June 22, 2017
  • by AydinHassan
  • Repository
  • 4 Watchers
  • 35 Stars
  • 471 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 2 % Grown

The README.md

Progress Bar Log

Display a progress bar and a portion of a log at the same time on the CLI!, (*1)

Preview, (*2)

Click the image above to see it in action., (*3)

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., (*4)

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:, (*5)

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., (*6)

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

<?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

The Versions

22/06 2017

dev-master

9999999-dev https://github.com/AydinHassan/progress-bar-log

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

  Sources   Download

MIT

The Requires

 

The Development Requires

log console cli progress

22/06 2017

1.3.1

1.3.1.0 https://github.com/AydinHassan/progress-bar-log

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

  Sources   Download

MIT

The Requires

 

The Development Requires

log console cli progress

03/04 2017

1.3.0

1.3.0.0 https://github.com/AydinHassan/progress-bar-log

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

  Sources   Download

MIT

The Requires

 

The Development Requires

log console cli progress

03/04 2017

1.2.0

1.2.0.0 https://github.com/AydinHassan/progress-bar-log

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

  Sources   Download

MIT

The Requires

 

The Development Requires

log console cli progress

02/04 2017

1.1.0

1.1.0.0 https://github.com/AydinHassan/progress-bar-log

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

  Sources   Download

MIT

The Requires

 

The Development Requires

log console cli progress

23/03 2017

1.0.0

1.0.0.0 https://github.com/AydinHassan/progress-bar-log

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

  Sources   Download

MIT

The Requires

 

The Development Requires

log console cli progress