PHPackages                             auron-consulting-oss/php-console-logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. auron-consulting-oss/php-console-logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

auron-consulting-oss/php-console-logger
=======================================

Simple PSR-3 compliant console logger for PHP

v2.0.0(6y ago)35.6k4Apache-2.0PHPPHP &gt;=7.2.0

Since Aug 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/luispabon/php-console-logger)[ Packagist](https://packagist.org/packages/auron-consulting-oss/php-console-logger)[ RSS](/packages/auron-consulting-oss-php-console-logger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (6)Used By (4)

[![Build status](https://camo.githubusercontent.com/c8466741511d2d5308023b7a969ef2e74cb206adb25074adc854c2acc6697259/68747470733a2f2f63692e6175726f6e636f6e73756c74696e672e636f2e756b2f6170692f76312f7465616d732f6d61696e2f706970656c696e65732f7068702d636f6e736f6c652d6c6f676765722d6d61737465722f6a6f62732f616e616c797a652d6d61737465722f6261646765)](https://ci.auronconsulting.co.uk/teams/main/pipelines/php-console-logger-master)[![Code coverage](https://camo.githubusercontent.com/3008515cdef2b39a9573e7a24bd7e1cec97c13cf9003a8522e534adb91f34082/68747470733a2f2f636f6465636f762e696f2f67682f6c7569737061626f6e2f7068702d636f6e736f6c652d6c6f676765722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/luispabon/php-console-logger)

PHP Console Logger
==================

[](#php-console-logger)

PhpConsoleLogger is a small class that implements a way to display messages in a console with an interface which is PSR-3 compatible. This means you can drop it in as a logger on code that is PSR-3 LoggerAwareInterface compatible and away you go.

This logger is really meant to be used for command line scripts due to shell-specific colouring commands.

You might want to use this on those command line scripts we all use to do things like migrations, data fixes etc; without the overhead of adding a full-on PHP console suite.

Requirements
------------

[](#requirements)

PHP 7.2+ ext-json

Installation
------------

[](#installation)

The preferred method is through composer, via `composer require auron-consulting-oss/php-console-logger`. You can always download and install manually, but you'd need to somehow shoehorn both psr/log and PhpConsoleLogger into your autoload mechanism.

Upgrading
---------

[](#upgrading)

If upgrading from 1.x, the logger will now by default print a timestamp next to the log message. You can disable it by passing `false` to the constructor.

Usage
-----

[](#usage)

```
// No timestamps
$consoleLogger = new AuronConsultingOSS\Logger\Console(false);

// With timestamps (default)
$console = new AuronConsultingOSS\Logger\Console(true);

[ ... ]

// Then, simply use like a regular PSR-3 logger
$console->info('Whatever', ['extra_stuff' => 'maybe']);
```

Contributing
------------

[](#contributing)

Fork this repo, do your stuff, send a PR. Tests are mandatory:

- PHP unit coverage must be 100%
- Infection MSI must be 100%
- PHPStan must show no errors

The provided [Makefile](Makefile) has all the basic test targets and is what's in use in CI.

Examples
--------

[](#examples)

I have provided with an example (code and output below) you can run by running `php example/example.php`.

```
