ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
CouchDBHandler.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
12namespace Monolog\Handler;
13
16
23{
24 private $options;
25
26 public function __construct(array $options = array(), $level = Logger::DEBUG, $bubble = true)
27 {
28 $this->options = array_merge(array(
29 'host' => 'localhost',
30 'port' => 5984,
31 'dbname' => 'logger',
32 'username' => null,
33 'password' => null,
34 ), $options);
35
36 parent::__construct($level, $bubble);
37 }
38
42 protected function write(array $record)
43 {
44 $basicAuth = null;
45 if ($this->options['username']) {
46 $basicAuth = sprintf('%s:%s@', $this->options['username'], $this->options['password']);
47 }
48
49 $url = 'http://'.$basicAuth.$this->options['host'].':'.$this->options['port'].'/'.$this->options['dbname'];
50 $context = stream_context_create(array(
51 'http' => array(
52 'method' => 'POST',
53 'content' => $record['formatted'],
54 'ignore_errors' => true,
55 'max_redirects' => 0,
56 'header' => 'Content-type: application/json',
57 )
58 ));
59
60 if (false === @file_get_contents($url, null, $context)) {
61 throw new \RuntimeException(sprintf('Could not connect to %s', $url));
62 }
63 }
64
68 protected function getDefaultFormatter()
69 {
71 }
72}
Encodes whatever record data is passed to it as json.
Base Handler class providing the Handler structure.
__construct(array $options=array(), $level=Logger::DEBUG, $bubble=true)
getDefaultFormatter()
Gets the default formatter.FormatterInterface
write(array $record)
Writes the record down to the log of the implementing handler.void
Monolog log channel.
Definition: Logger.php:28
const DEBUG
Detailed debug information.
Definition: Logger.php:32
$url
Definition: shib_logout.php:72