ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
MongoDBHandler.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
29{
31
32 public function __construct($mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true)
33 {
34 if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) {
35 throw new \InvalidArgumentException('MongoClient or Mongo instance required');
36 }
37
38 $this->mongoCollection = $mongo->selectCollection($database, $collection);
39
40 parent::__construct($level, $bubble);
41 }
42
43 protected function write(array $record)
44 {
45 $this->mongoCollection->save($record["formatted"]);
46 }
47
51 protected function getDefaultFormatter()
52 {
53 return new NormalizerFormatter();
54 }
55}
Normalizes incoming records to remove objects/resources so it's easier to dump to various targets.
Base Handler class providing the Handler structure.
Logs to a MongoDB database.
__construct($mongo, $database, $collection, $level=Logger::DEBUG, $bubble=true)
write(array $record)
Writes the record down to the log of the implementing handler.
getDefaultFormatter()
Gets the default formatter.FormatterInterface
Monolog log channel.
Definition: Logger.php:28
const DEBUG
Detailed debug information.
Definition: Logger.php:32