2017 © Pedro Peláez
 

library log

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

image

consolidation/log

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  • Friday, May 25, 2018
  • by greg.1.anderson
  • Repository
  • 1 Watchers
  • 70 Stars
  • 1,642,853 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 19 Versions
  • 23 % Grown

The README.md

Consolidation\Log

Improved PSR-3 Psr\Log logger based on Symfony Console components., (*1)

ci scrutinizer codecov license, (*2)

Component Status

In use in Robo., (*3)

Motivation

Consolidation\Log provides a PSR-3 compatible logger that provides styled log output to the standard error (stderr) stream. By default, styling is provided by the SymfonyStyle class from the Symfony Console component; however, alternative stylers may be provided if desired., (*4)

Usage

$logger = new \Consolidation\Log\Logger($output);
$logger->setLogOutputStyler(new LogOutputStyler()); // optional
$logger->warning('The file {name} does not exist.', ['name' => $filename]);

String interpolation -- that is, the substitution of replacements, such as {name} in the example above, is not required by PSR-3, and is not implemented by default in the Psr\Log project. However, it is recommended by PRS-3, and is often done, e.g. in the Symfony Console logger., (*5)

Consolidation\Log supports string interpolation., (*6)

A logger manager can be used to delegate all log messages to one or more loggers., (*7)

$logger = new \Consolidation\Log\LoggerManager();
$logger->add('default', new \Consolidation\Log\Logger($output));

This is useful if, for example, you need to inject a logger into application objects early (e.g. into a dependency injection container), but the output object to log to will not be available until later., (*8)

Comparison to Existing Solutions

Many Symfony Console compoenents use SymfonyStyle to format their output messages. This helper class has methods named things like success and warning, making it seem like a natural choice for reporting status., (*9)

However, in practice it is much more convenient to use an actual Psr-3 logger for logging. Doing this allows a Symfony Console component to call an external library that may not need to depend on Symfony Style. Having the Psr\Log\LoggerInterface serve as the only shared IO-related interface in common between the console tool and the libraries it depends on promots loose coupling, allowing said libraries to be re-used in other contexts which may wish to log in different ways., (*10)

Symfony Console provides the ConsoleLogger to fill this need; however, ConsoleLogger does not provide any facility for styling output, leaving SymfonyStyle as the preferred logging mechanism for style-conscienscious console coders., (*11)

Consolidation\Log provides the benefits of both classes, allowing for code that both behaved technically correctly (redirecting to stderr) without sacrificing on style., (*12)

Monolog also provides a full-featured Console logger that might be applicable for some use cases., (*13)

The Versions

25/05 2018

dev-master

9999999-dev

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

25/05 2018

1.0.6

1.0.6.0

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

25/05 2018

dev-g1a

dev-g1a

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

04/12 2017

dev-composer-scenarios

dev-composer-scenarios

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

30/11 2017

dev-split-out-scenarios

dev-split-out-scenarios

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

29/11 2017

1.0.5

1.0.5.0

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

29/11 2017

dev-test-multiple-symfony-versions

dev-test-multiple-symfony-versions

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

21/11 2017

1.0.4

1.0.4.0

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

04/02 2017

dev-phpunit6

dev-phpunit6

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

21/12 2016

dev-interpolation-compatibility

dev-interpolation-compatibility

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

25/04 2016

dev-coveralls

dev-coveralls

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

24/03 2016

1.0.3

1.0.3.0

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires

22/03 2016

1.0.2

1.0.2.0

Improved Psr-3 / Psr\Log logger based on Symfony Console components.

  Sources   Download

MIT

The Requires

 

The Development Requires