vagrus / monolog-yii-ar-handler
A Monolog handler for send logs in Yii Active Record model
Installs: 3 748
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.0
- monolog/monolog: ~1.17.1
- yiisoft/yii: ^1.1
Requires (Dev)
- phpunit/phpunit: ~4.5
- phpunit/phpunit-mock-objects: 2.3.0
This package is auto-updated.
Last update: 2024-10-29 04:53:00 UTC
README
These handler make it easy to send logs to Yii AR model.
Installation
Install the latest version with
$ composer require vagrus/monolog-yii-ar-handler
Basic Usage
<?php use Monolog\Logger; use Vagrus\Monolog\Handler\YiiArHandler; $mappingSettings = array( '*' => 'modelProperty', // required ); // create a log channel $log = new Logger('name'); $log->pushHandler(new YiiArHandler('modelName', $mappingSettings, Logger::WARNING)); // add records to the log $log->warning('Foo');
Extended Usage
<?php use Monolog\Logger; use Vagrus\Monolog\Handler\YiiArHandler; $mappingSettings = array( '*' => 'property1', // required 'contextVar1' => 'property2', 'contextVar2' => 'property3', ); // create a log channel $log = new Logger('name'); $log->pushHandler(new YiiArHandler('modelName', $mappingSettings, Logger::WARNING)); // add records to the log // 'Foo' will be written to model's property1, 'some context value' to property2, etc. $context = array( 'contextVar1' => 'some context value', 'contextVar2' => 'other context value', ); $log->warning('Foo', $context);