yii2-extended / yii2-psr3-logger-bridge
A library to bridge psr-3 loggers with the yii logging system
Requires
- php: >=8.0
- psr/log: ^3
- yiisoft/yii2: ^2
Requires (Dev)
- dev-master
- 7.0.7
- 7.0.6
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.0.7
- 6.0.6
- 6.0.5
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.0.1
- 5.0.0
- 4.0.2
- 4.0.1
- 4.0.0
- 3.1.31
- 3.1.30
- 3.1.29
- 3.1.28
- 3.1.27
- 3.1.26
- 3.1.25
- 3.1.24
- 3.1.23
- 3.1.22
- 3.1.21
- 3.1.20
- 3.1.19
- 3.1.18
- 3.1.17
- 3.1.16
- 3.1.15
- 3.1.14
- 3.1.13
- 3.1.12
- 3.1.11
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.0
- 1.2.0
- 1.1.0
- 1.0.0
This package is auto-updated.
Last update: 2024-10-31 00:34:32 UTC
README
A library to bridge psr-3 loggers with the yii logging system
Installation
The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.
- Download
composer.phar
from their website. - Then run the following command to install this library as dependency :
php composer.phar yii2-extended/yii2-psr3-logger-bridge ^7
Basic Usage
This library offers one psr3 compliant logger to log messages back to yii2 logging system. As Yii2 has a limited number of logging levels, this logger will attempt to use the closest Yii2 equivalent for the provided psr3 level.
If you are searching for the reverse (yii2 logger that logs to psr3 compliant targets, look at the official yii2-psr-log-target.
The Psr3ToYii2Logger
is straightforward to use, just look at the
PSR-3 documentation.
Any message that is logged by this logger will be transmitted to Yii's
application log
component.
use Yii2Extended\Yii2Log\Psr3ToYii2Logger;
use Psr\Log\LogLevel;
use yii\log\Logger;
$logger = new Psr3ToYii2Logger();
// with the psr3 methods
$logger->emergency('A psr3 emergency message, logged as Yii2 error message');
// with the psr3 log levels
$logger->log(LogLevel::ALERT, 'A psr3 alert message, logged as Yii2 error message');
// with the yii2 log levels
$logger->log(Logger::LEVEL_PROFILE_BEGIN, 'A yii2 profile begin message, logged as profile begin message');
Note that the messages that are passed through this component may use optionals
__category__
and __language__
keys within the $context
array. This
will be useful to orient the category of the logging message, and the language
in which it should be translated, in case of need (as the translation to yii
interpolates the message with the context and tries to translate it, using the
Yii::t()
method).
License
MIT (See license file).