Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vjik/yii2-psr-logger-proxy
PSR-3 compatible logger proxy for Yii2
https://github.com/vjik/yii2-psr-logger-proxy
Last synced: about 4 hours ago
JSON representation
PSR-3 compatible logger proxy for Yii2
- Host: GitHub
- URL: https://github.com/vjik/yii2-psr-logger-proxy
- Owner: vjik
- License: bsd-3-clause
- Created: 2020-08-01T10:57:19.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-02T10:53:32.000Z (over 4 years ago)
- Last Synced: 2024-04-01T16:20:59.355Z (8 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PSR-3 compatible logger proxy for Yii2
## Installation
The preferred way to install this extension is through [composer](https://getcomposer.org/download/):
```
composer require vjik/yii2-psr-logger-proxy
```## Base usage
```php
use Vjik\Yii2\Psr\LoggerProxy\LoggerProxy;$loggerProxy = new LoggerProxy(\Yii::getLogger());
```## Advanced usage
```php
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;
});
```