for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* (c) Kris Wallsmith <[email protected]> (https://github.com/doctrine/DoctrineMongoDBBundle/)
*/
namespace Chubbyphp\ServiceProvider\Logger;
use Psr\Log\LoggerInterface;
class DoctrineMongoDbLogger
{
/**
* @var LoggerInterface
private $logger;
* @var int
private $batchInsertThreshold;
* @var string
private $prefix;
* @param LoggerInterface $logger
* @param int $batchInsertThreshold
* @param string $prefix
public function __construct(LoggerInterface $logger, int $batchInsertThreshold, string $prefix)
$this->logger = $logger;
$this->batchInsertThreshold = $batchInsertThreshold;
$this->prefix = $prefix;
}
* @param array $query
public function logQuery(array $query)
if (null === $this->logger) {
return;
if (isset($query['batchInsert'])
&& null !== $this->batchInsertThreshold && $this->batchInsertThreshold <= $query['num']) {
$query['data'] = '**'.$query['num'].' item(s)**';
array_walk_recursive($query, function (&$value, $key) {
$key
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
if ($value instanceof \MongoBinData) {
$value = base64_encode($value->bin);
if (is_float($value) && is_infinite($value)) {
$value = ($value < 0 ? '-' : '').'Infinity';
if (is_float($value) && is_nan($value)) {
$value = 'NaN';
});
$this->logger->debug($this->prefix.json_encode($query));
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.