Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aydinhassan/progress-bar-log
A component to display a progress bar and last X logs at the same time.
https://github.com/aydinhassan/progress-bar-log
cli console error-handling logging php progress-bar
Last synced: 3 months ago
JSON representation
A component to display a progress bar and last X logs at the same time.
- Host: GitHub
- URL: https://github.com/aydinhassan/progress-bar-log
- Owner: AydinHassan
- License: mit
- Created: 2017-03-23T18:23:06.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-06-01T10:48:49.000Z (over 2 years ago)
- Last Synced: 2023-12-19T15:02:16.513Z (about 1 year ago)
- Topics: cli, console, error-handling, logging, php, progress-bar
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 41
- Watchers: 5
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Progress Bar Log
Display a progress bar and a portion of a log at the same time on the CLI!
[![Preview](https://asciinema.org/a/dnyvr047wc0dfdrbalalau38n.png)](https://asciinema.org/a/dnyvr047wc0dfdrbalalau38n)
Click the image above to see it in action.
## Installation
```sh
$ 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
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:
```sh
git clone [email protected]: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
getProgressBar()->setFormat('normal');
$progressLog->getProgressBar()->setBarWidth(50);
$progressLog->start();
```## Running unit tests
```sh
$ composer test
```