src/Expose/Log/Mongo.php
public function log($level, $message, array $context = array())
    {
        $logger = new \Monolog\Logger('audit');
        try {
            $handler = new \Monolog\Handler\MongoDBHandler(
                new \Mongo($this->getConnectString()),
                $this->getDbName(),
                $this->getDbCollection()
            );
        } catch (\MongoConnectionException $e) {
            throw new \Exception('Cannot connect to Mongo - please check your server');
        }
        $logger->pushHandler($handler);
        $logger->pushProcessor(function ($record) {
            $record['datetime'] = $record['datetime']->format('U');
            return $record;
        });

        return $logger->$level($message, $context);
    }
public function log($level, $message, array $context = array())
    {
        $logger = new \Monolog\Logger('audit');
        try {
            $handler = new \Monolog\Handler\MongoDBHandler(
                new \Mongo($this->getConnectString()),
                $this->getDbName(),
                $this->getDbCollection()
            );
        } catch (\MongoConnectionException $e) {
            throw new \Exception('Cannot connect to Mongo - please check your server');
        }
        $logger->pushHandler($handler);
        $logger->pushProcessor(function ($record) {
            $record['datetime'] = $record['datetime']->format('U');
            return $record;
        });

        return $logger->$level($message, $context);
    }
public function log ( $ level , $ message , array $ context = array ( ) ) { $ logger = new \ Monolog \ Logger ( 'audit' ) ; try { $ handler = new \ Monolog \ Handler \ MongoDBHandler ( new \ Mongo ( $ this -> getConnectString ( ) ) , $ this -> getDbName ( ) , $ this -> getDbCollection ( ) ) ; } catch ( \ MongoConnectionException $ e ) { throw new \ Exception ( 'Cannot connect to Mongo - please check your server' ) ; } $ logger -> pushHandler ( $ handler ) ; $ logger -> pushProcessor ( function ( $ record ) { $ record [ 'datetime' ] = $ record [ 'datetime' ] -> format ( 'U' ) ; return $ record ; } ) ; return $ logger -> $ level ( $ message , $ context ) ; }
Push the log message and context information into Mongo

@param string $level Logging level (ex. info, debug, notice...)
@param string $message Log message
@param array $context Extra context information
@return boolean Success/fail of logging
Push the log message and context information into Mongo