Download the PHP package devengine/monolog-colored-line-formatter without Composer
On this page you can find all versions of the php package devengine/monolog-colored-line-formatter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devengine/monolog-colored-line-formatter
More information about devengine/monolog-colored-line-formatter
Files in devengine/monolog-colored-line-formatter
Package monolog-colored-line-formatter
Short Description Colored Line Formatter for Monolog
License MIT
Informations about the package monolog-colored-line-formatter
Monolog Colored Line Formatter
A Formatter for Monolog with color support Built by Bramus! - https://www.bram.us/
About
bramus/monolog-colored-line-formatter
is a formatter for use with Monolog. It augments the Monolog LineFormatter by adding color support. To achieve this bramus/monolog-colored-line-formatter
uses ANSI Escape Sequences – provided by bramus/ansi-php
– which makes it perfect for usage on text based terminals (viz. the shell).
bramus/monolog-colored-line-formatter
ships with a default color scheme, yet it can be adjusted to fit your own needs.
Prerequisites/Requirements
- PHP 7.2 or greater
- Monolog 2.0 or greater
Looking for a version compatible with Monolog 1.x? Check out the monolog-1.x
branch then. The version of monolog-colored-line-formatter
that is compatible with Monolog 1.x, is monolog-colored-line-formatter
version ~2.0
Installation
Installation is possible using Composer.
Install monolog-colored-line-formatter
, compatible with Monolog 2.x:
Install monolog-colored-line-formatter
, compatible with Monolog 1.x:
Usage
Create an instance of \Bramus\Monolog\Formatter\ColoredLineFormatter
and set it as the formatter for the \Monolog\Handler\StreamHandler
that you use with your \Monolog\Logger
instance.
Color Schemes
Available Color Schemes
Color Scheme: DefaultScheme
Color Scheme: TrafficLight
Activating a Color Scheme
Color Schemes are defined as classes. If you do not provide any color scheme the default one will be used.
To activate a color scheme pass it as the first argument of the ColoredLineFormatter
Constructor. All successive arguments are the ones as required by the \Monolog\Formatter\LineFormatter
class.
Alternatively it's also possible to activate it using the setColorScheme()
method of a ColoredLineFormatter
instance.
Creating your own Custom Color Scheme
To define your own color scheme make a class that implements the \Bramus\Monolog\Formatter\ColorSchemes\ColorSchemeInterface
interface. To make things more easy a trait ColorSchemeTrait
is defined.
Please refer to the bramus/ansi-php
documentation to define your own styles and colors.
Unit Testing
bramus/monolog-colored-line-formatter
ships with unit tests using PHPUnit.
-
If PHPUnit is installed globally run
phpunit
to run the tests. - If PHPUnit is not installed globally, install it locally through composer by running
composer install --dev
. Run the tests themselves by callingvendor/bin/phpunit
.
Unit tests are also automatically run on GitHub Actions
License
bramus/monolog-colored-line-formatter
is released under the MIT public license. See the enclosed LICENSE.txt
for details.