PHP code example of vjik / yii2-psr-logger-proxy
1. Go to this page and download the library: Download vjik/yii2-psr-logger-proxy 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/ */
vjik / yii2-psr-logger-proxy example snippets
use Vjik\Yii2\Psr\LoggerProxy\LoggerProxy;
$loggerProxy = new LoggerProxy(\Yii::getLogger());
use Vjik\Yii2\Psr\LoggerProxy\LoggerProxy;
// Create proxy
$loggerProxy = new LoggerProxy(\Yii::getLogger());
// Set default Yii2 log category (default "application")
$loggerProxy->setDefaultCategory('psr-3');
// Add PSR-3 log context params for use as Yii2 log category
$loggerProxy->addCategoryParam('category');
$loggerProxy->addCategoryParam('type');
// Set custom function for prepare PSR-3 log message tot Yii2 log message
// Return message or NULL for use internal prepare message function.
$loggerProxy->setPrepareMessage(function ($message, $context) {
if (isset($context['elapsed'])) {
return 'Query (' . $context['elapsed'] . ' ms):' . "\n" . $message;
}
return null;
});