consolidation/log
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
psr/log | 3.0.0 | 6.77 kB | MIT | prod dev | |
symfony/console | v6.4.7 | - | MIT | prod |
The Consolidation/Log package serves as an advanced PSR-3 and Psr\Log logger, built on Symfony Console components. This upgraded logger is specifically designed to give you stylish, standard error log outputs that are PSR-3 compatible. It is utilized in the popular task automation tool, Robo, highlighting its functionality and reliability. The key attribute of Consolidation/Log is its ability to support string interpolation, not natively provided by Psr\Log, thereby allowing easy substitution of replacements in logged messages.
To use Consolidation/Log, start by creating a new instance of the Logger, using an output object as the argument. Optionally, you can set a custom LogOutputStyler. To log a warning, use the warning
method of the Logger instance, passing a message and an associated array of replacements if necessary.
Here's an example:
$logger = new \Consolidation\Log\Logger($output);
$logger->setLogOutputStyler(new LogOutputStyler()); // optional
$logger->warning('The file {name} does not exist.', ['name' => $filename]);
For applications that need one or more loggers, the package offers a Logger manager. You create a new LoggerManager instance, then add a logger to it using the add
method. An identifier and a new Logger instance are required as arguments.
$logger = new \Consolidation\Log\LoggerManager();
$logger->add('default', new \Consolidation\Log\Logger($output));
For more in-depth knowledge on how to benefit from Consolidation/Log's capabilities, reviews, and usage examples, the documentation is readily available on the GitHub repository README page - https://github.com/consolidation/log. The README provides detailed insights about the package's motivation, functionality, usage examples, and how it compares to other existing solutions in the market. Feel free to visit the link to further grasp the capabilities of using this advanced and stylish logger for your PHP projects.