/usr/share/php/Analog/Handler/Mongo.php is in php-analog 1.0.7-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <?php
namespace Analog\Handler;
/**
* Send the log message to the specified collection in a
* MongoDB database.
*
* Usage:
*
* Analog::handler (Analog\Handler\Mongo::init (
* 'localhost:27017', // connection string
* 'mydb', // database name
* 'log' // collection name
* ));
*
* Alternately, if you have an existing Mongo connection,
* you can simply initialize it with that:
*
* $conn = new MongoClient ('localhost:27017');
* Analog::handler (Analog\Handler\Mongo::init (
* $conn, // Mongo object
* 'mydb', // database name
* 'log' // collection name
* ));
*/
class Mongo {
public static function init ($server, $database, $collection) {
if ($server instanceof \MongoClient) {
$db = $server->{$database};
} else {
$conn = new \MongoClient ("mongodb://$server");
$db = $conn->{$database};
}
return function ($info) use ($db, $collection) {
$db->{$collection}->insert ($info);
};
}
}
|