dev-master
9999999-devA PSR/3 log producer for MongoDB
GPL-2.0+
The Requires
- psr/log ^1.0
- php >5.4.0
Wallogit.com
2017 © Pedro PelĂĄez
A PSR/3 log producer for MongoDB
This is an OSInet logger for MongoDB: it enables your PHP application to dump
the low-level operations performed by the mongo extension communicating with
your mongod or mongos instance., (*1)
It does not provide a PSR-3 logging destination, but a way to gather
information from your MongoDB-using code, and pushing it to your choice of PSR-3
logger (e.g Monolog in general PHP code, or mongodb_watchdog in Drupal 6/7/8)., (*2)
This code requires the legacy mongo extension: these features have been
removed from the newer mongodb (phongo) extension:, (*3)
(c) 2015 Ouest Systèmes Informatiques, (*4)
Licensed under the General Public License version 2 or later., (*5)
localhost:27017. Any data in the instance could be lost.clone the repository, (*6)
https://github.com/FGM/mongodb_logger.git cd mongodb_logger
run composer install to fetch dependencies, (*7)
that's it: you can now run the demo in the package itself, (*8)
`php loguser.php`.
localhost:27017. Any data in the instance could be lost.create a composer file, (*9)
mkdir my_demo cd my_demo composer init
answer the usual Composer questions, when Composer asks for requirements, request fgm/mongodb_logger, do not specify a version, (*10)
install dependencies, (*11)
composer install
copy the loguser.php file to your project directory, (*12)
cp vendor/fgm/mongodb_logger/loguser.php .
that's it: you can now run the demo as a separate application, (*13)
php loguser.php
instantiate the Logger\Emitter as your code needs it. A DIC may help., (*14)
use FGM\MongoDBLogger\Logger\Emitter; use Psr\Log\LogLevel; // Build an emitter. $emitter = new Emitter(); // Inject your own PSR-3 logger. $emitter->setLogger($logger); // You can choose your log level. $emitter->setLogLevel(LogLevel::DEBUG);
use the emitter to create the mongodb:// context for your app., (*15)
$context = $emitter->createContext();
pass the context you just built when connecting to MongoDB., (*16)
$client = new \MongoClient($server, $options, ['context' => $context]);
that'it. All your operations are now ready to be logged., (*17)
A PSR/3 log producer for MongoDB
GPL-2.0+