1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-08 14:16:42 +02:00

Merge remote-tracking branch 'armetiz/master'

This commit is contained in:
Jordi Boggiano
2012-04-22 11:32:38 +02:00

View File

@@ -0,0 +1,42 @@
<?php
/*
* This file is part of the Monolog package.
*
* (c) Thomas Tourlourat <thomas@tourlourat.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Monolog\Handler;
use Monolog\Logger;
/**
* Logs to a MongoDB database.
*
* usage example:
*
* $log = new Logger('application');
* $mongodb = new MongoDBHandler(new \Mongo("mongodb://localhost:27017"), "logs", "prod");
* $log->pushHandler($mongodb);
*
* @author Thomas Tourlourat <thomas@tourlourat.com>
*/
class MongoDBHandler extends AbstractProcessingHandler {
private $mongoCollection;
public function __construct(\Mongo $mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true) {
$this->mongoCollection = $this->mongo->selectCollection($database, $collection);
parent::__construct($level, $bubble);
}
protected function write(array $record) {
unset($record["formatted"]);
$this->mongoCollection->save($record);
}
}