ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
RedisHandler.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Monolog package.
5  *
6  * (c) Jordi Boggiano <j.boggiano@seld.be>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Monolog\Handler;
13 
15 use Monolog\Logger;
16 
29 {
30  private $redisClient;
31  private $redisKey;
32 
39  public function __construct($redis, $key, $level = Logger::DEBUG, $bubble = true)
40  {
41  if (!(($redis instanceof \Predis\Client) || ($redis instanceof \Redis))) {
42  throw new \InvalidArgumentException('Predis\Client or Redis instance required');
43  }
44 
45  $this->redisClient = $redis;
46  $this->redisKey = $key;
47 
48  parent::__construct($level, $bubble);
49  }
50 
51  protected function write(array $record)
52  {
53  $this->redisClient->rpush($this->redisKey, $record["formatted"]);
54  }
55 
59  protected function getDefaultFormatter()
60  {
61  return new LineFormatter();
62  }
63 }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
Base Handler class providing the Handler structure.
Logs to a Redis key using rpush.
__construct($redis, $key, $level=Logger::DEBUG, $bubble=true)
Formats incoming records into a one-line string.