curruwilla/console-pretty-log

Simple and customizable console log output for CLI apps.

1.2 2022-08-02 15:04 UTC

This package is auto-updated.

Last update: 2022-10-01 00:10:42 UTC


README

PHP from Packagist Latest Version Software License Build Quality Score Total Downloads

Simple and customizable console log output for CLI apps.

Highlights

  • Simple installation (Instalação simples)
  • Very easy to customize text output (Muito fácil de customizar a saída de texto)
  • Composer ready and PSR-12 compliant (Pronto para o composer e compatível com PSR-12)

Installation

Uploader is available via Composer:

"curruwilla/console-pretty-log": "^1.0"

or run

composer require curruwilla/console-pretty-log

Documentation

Check the example file.

If you are defining the size of columns, when using textInitial be sure to enter the size as well.

Example:

use ConsolePrettyLog\Background;
use ConsolePrettyLog\Color;
use ConsolePrettyLog\Font;
use ConsolePrettyLog\Line;

$line = new Line();
$line->columnsSize([15, 75, 10]); // <-- Use to keep information aligned
//$line->separator('-'); <-- Default value: '|'
//$line->paddingCharacter(' '); <-- Default value: '.'
//$line->enableDate(false); <-- Default value: true
//$line->dateFormat("d/m/Y H:i"); <-- Default value: 'Y-m-d H:i:s'
//$line->textInitial('LOG', [Color::RED, Font::BOLD]); <-- Include text at the beginning of every line
//$line->textInitial('IMPORTANT', [Font::BOLD]); <-- Include text at the beginning of every line

$line
    ->text('Account 1', [Font::BOLD, Font::ITALIC])
    ->text('Delivery made successfully', [Color::WHITE])
    ->text('Success', [Color::GREEN])
    ->print();

$line
    ->text('Account 2', [Font::BOLD])
    ->text('Opps, something went wrong with the delivery, please see the log', [Color::WHITE])
    ->text('Error', [Background::RED])
    ->print();

$line
    ->text('Account 3', [Font::BOLD])
    ->text('Payment made successfully', [Color::WHITE, Font::ITALIC])
    ->text('SUCCESS', [Background::GREEN])
    ->print();

$line
    ->text('Account 1', [Font::BOLD])
    ->text('Payment made successfully', [Color::WHITE])
    ->text('INFO', [Background::BLUE])
    ->print();

Result in CLI:

example.png

Enums Options:

options_enums.png

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.