PHP code example of davidburger / expressive-logger

1. Go to this page and download the library: Download davidburger/expressive-logger 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/ */

    

davidburger / expressive-logger example snippets


'exceptionFormatterCallback' => function($exception, &$context) {

    if (true === empty($context)) {
        $context = ['exception' => $exception];
    }

    return sprintf('Exception %s: "%s" at %s line %s',
        get_class($exception),
        $exception->getMessage(),
        $exception->getFile(),
        $exception->getLine()
    );
},

'messageFormatter' => \ExpressiveLogger\MessageFormatter\DefaultFormatter::class



var \Interop\Container\ContainerInterface $container */
$container = ainer);


use ExpressiveLogger\LoggerFacade;
//..

try {

} catch(RuntimeException $e) {
   LoggerFacade::error($e);
}

'dependencies' => [
    'factories' => [
        \Monolog\Handler\RedisHandler::class => \ExpressiveLogger\Factory\RedisHandlerFactory::class,
    ],
],
'expressiveLogger' => [
    'handlers' => [
        'redis' => [
            'client' => 'redisClient',  //name of redis instance available via container
            'key' => 'logstash',
            'level' => Logger::DEBUG,
        ],
    ]
]
sh
cd <project_root>
cp vendor/davidburger/expressive-logger/config/errorlog.global.php.dist config/autoload/errorlog.global.php