PHP code example of hikaeme / monolog-ltsv-formatter

1. Go to this page and download the library: Download hikaeme/monolog-ltsv-formatter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hikaeme / monolog-ltsv-formatter example snippets


use Monolog\Level;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Hikaeme\Monolog\Formatter\LtsvFormatter;

$log = new Logger('DEMO');
$handler = new StreamHandler('php://stdout', Level::Error);
$handler->setFormatter(new LtsvFormatter('Y-m-d H:i:s'));
$log->pushHandler($handler);

$log->error('Something happened', ['detail1' => 'foo', 'detail2' => 'bar']);
// time:2016-01-02 11:58:03<tab>level:ERROR<tab>message:Something happened<tab>detail1:foo<tab>detail2:bar