kmelia/monolog-stdout-handler

A handler for Monolog that sends messages to stdout (with color).

1.2.1 2015-10-23 16:14 UTC

README

Latest Stable Version Build Status

Provides a handler for Monolog that sends colored messages to stdout. Messages may be uncolored with a provided formatter.

Loggers are able to interprete a balise language (like bbcode) Balises currently recognized are :

  • [c=<color>]...[/c] with color: black, blue, green, cyan, red, purple, yellow, white

Example

How to use the stdout handler:

<?php
use Monolog\Logger;
use Monolog\Handler\StdoutHandler;

$stdoutHandler = new StdoutHandler();
$logger = new Logger('cronjob');
$logger->pushHandler($stdoutHandler);

$logger->error('[c=green]Hello world![/c]');

How to remove the colored formatter:

<?php
use Monolog\Formatter\NoColorLineFormatter;
  
$stdoutHandler->setFormatter(new NoColorLineFormatter(StdoutHandler::FORMAT));