Skip to content

Commit

Permalink
[UPDATE] Redis Handler config data update and updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Oras Al-Kubaisi committed Jun 3, 2016
1 parent 7cd8b5f commit f593812
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ $logglyHandler = [
'loggly' =>
[
'type' => 'loggly',
'token' => 'your-loggly-token',
'token' => 'your-loggly-token',
'level' => Logger::DEBUG,
'bubble' => true, //optional
],
Expand Down Expand Up @@ -158,6 +158,21 @@ $browserConsoleHandler = [
],
];
```

##### Redis handler
```php
$redisHandler = [
'redis' =>
[
'type' => 'redis',
'level' => Logger::DEBUG,
'redis_client' => new \Redis(),
'key' => 'monolog',
],
];
```


#### Extending Middleware

To extend the middleware to log your own format, or specific data like cookies, server params .. etc. You can do that easily using the following steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function getHandler($name, $handlerConfig)
$bubble = (isset($handlerConfig['bubble']) ? $handlerConfig['bubble'] : true);
$capSize = (isset($handlerConfig['cap_size']) ? $handlerConfig['cap_size'] : false);

return new RedisHandler($handlerConfig['redis'], $handlerConfig['key'], $bubble, $capSize);
return new RedisHandler($handlerConfig['redis_client'], $handlerConfig['key'], $bubble, $capSize);
break;
case 'rotating_file':
case 'swift_mailer':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class ValidateRedisHandlerConfigTest extends \PHPUnit_Framework_TestCase
public function testValidate()
{
$configArray = [
'type' => 'redis',
'level' => 'INFO',
'redis' => new \Redis(),
'key' => 'monolog'
'type' => 'redis',
'level' => 'INFO',
'redis_client' => new \Redis(),
'key' => 'monolog'
];

$redisValidator = new ValidateRedisHandlerConfig($configArray);
Expand All @@ -24,9 +24,9 @@ public function testValidate()
public function testHasRedisClient()
{
$configArray = [
'type' => 'redis',
'level' => 'INFO',
'redis' => new \Redis(),
'type' => 'redis',
'level' => 'INFO',
'redis_client' => new \Redis(),
];

$redisValidator = new ValidateRedisHandlerConfig($configArray);
Expand All @@ -49,9 +49,9 @@ public function testNotHasRedisClient()
public function testHasRedisValueButNotRedisClient()
{
$configArray = [
'type' => 'redis',
'level' => 'INFO',
'redis' => 'REDIS',
'type' => 'redis',
'level' => 'INFO',
'redis_client' => 'REDIS',
];
self::setExpectedException('MonologMiddleware\Exception\MonologConfigException');
$redisValidator = new ValidateRedisHandlerConfig($configArray);
Expand All @@ -76,7 +76,7 @@ public function testHasNoKey()
'type' => 'redis',
'level' => 'INFO',
];

self::setExpectedException('MonologMiddleware\Exception\MonologConfigException');
$redisValidator = new ValidateRedisHandlerConfig($configArray);
$this->assertTrue($redisValidator->hasKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function validate()
*/
public function hasRedisClient()
{
if (isset($this->handlerConfigArray['redis']) && $this->handlerConfigArray['redis'] instanceof \Redis) {
if (isset($this->handlerConfigArray['redis_client']) && $this->handlerConfigArray['redis_client'] instanceof \Redis) {
return true;
} else {
throw new MonologConfigException("Missing Redis client in Redis handler configuration");
Expand Down

0 comments on commit f593812

Please sign in to comment.