Logs a query to the specified logger

@param \Muffin\Webservice\Query $query The query to log
@param \Psr\Log\LoggerInterface $logger The logger instance to use
@return void
508065
protected function _logQuery(Query $query, LoggerInterface $logger)
    {
        if (!$this->getDriver()->isQueryLoggingEnabled()) {
            return;
        }

        $logger->debug($query->endpoint(), [
            'params' => $query->where()
        ]);
    }
1275214
public function setLogger(LoggerInterface $logger)
    {
        $this->traitSetLogger($logger);
        foreach ($this->connections as $connection) {
            $connection->setLogger($logger);
        }
    }
1008115
protected function log($message): void
    {
        if ($this->logger !== null) {
            $this->logger->log($message);
        }
    }
328998
protected function buildQueryCallback(LogManager $logger): callable
    {
        return function (QueryExecuted $query) use ($logger) {
            $sql = Str::replaceArray('?', $query->connection->prepareBindings($query->bindings), $query->sql);

            $logger->info("<comment>{$sql} [{$query->time}ms]</comment>");
        };
    }
1019318
protected function runQuery($tableName, $query)
    {
        try {
            return $this->connection->query($query);
        } catch (DBALException $e) {
            $this->loggerSystem->critical($e->getMessage(), ['event' => 'exception', 'exception' => $e]);
            $this->loggerFlash->error(
                Trans::__('An error occured while updating `%TABLE%`. The error is %ERROR%',
                ['%TABLE%' => $tableName, '%ERROR%' => $e->getMessage()]
            ));
        }

        return null;
    }
1273006
public function log(array $data)
    {
        $data['query'] = $this->query;
        $data['fields'] = $this->fields;
        call_user_func($this->loggerCallable, $data);
    }
782867
public function setLogger( LoggerInterface $logger ) {
		$this->logger = $logger;
		$this->session->setLogger( $logger );
	}
264283
private function logQuery($strQuery, $dblQueryTime)
    {
        if ($this->blnEnableProfiling) {
            // Dereference-ize Backtrace Information
            $objDebugBacktrace = debug_backtrace();

            // get rid of unnecessary backtrace info in case of:
            // query
            if ((count($objDebugBacktrace) > 3) &&
                (array_key_exists('function', $objDebugBacktrace[2])) &&
                (($objDebugBacktrace[2]['function'] == 'QueryArray') ||
                    ($objDebugBacktrace[2]['function'] == 'QuerySingle') ||
                    ($objDebugBacktrace[2]['function'] == 'QueryCount'))
            ) {
                $objBacktrace = $objDebugBacktrace[3];
            } else {
                if (isset($objDebugBacktrace[2])) // non query
                {
                    $objBacktrace = $objDebugBacktrace[2];
                } else // ad hoc query
                {
                    $objBacktrace = $objDebugBacktrace[1];
                }
            }

            // get rid of reference to current object in backtrace array
            if (isset($objBacktrace['object'])) {
                $objBacktrace['object'] = null;
            }

            for ($intIndex = 0, $intMax = count($objBacktrace['args']); $intIndex < $intMax; $intIndex++) {
                $obj = $objBacktrace['args'][$intIndex];

                if (is_null($obj)) {
                    $obj = 'null';
                } else {
                    if (gettype($obj) == 'integer') {
                    } else {
                        if (gettype($obj) == 'object') {
                            $obj = 'Object: ' . get_class($obj);
                            if (method_exists($obj, '__toString')) {
                                $obj .= '- ' . $obj;
                            }
                        } else {
                            if (is_array($obj)) {
                                $obj = 'Array';
                            } else {
                                $obj = sprintf("'%s'", $obj);
                            }
                        }
                    }
                }
                $objBacktrace['args'][$intIndex] = $obj;
            }

            // Push it onto the profiling information array
            $arrProfile = array(
                'objBacktrace' => $objBacktrace,
                'strQuery' => $strQuery,
                'dblTimeInfo' => $dblQueryTime
            );

            array_push($this->strProfileArray, $arrProfile);
        }
    }
312051
public function addLogger($loggerName, $logger)
    {
        if ($logger instanceof LoggerInterface) {
            self::$loggers[$loggerName] = $logger;
        } elseif ($this->debug) {
            throw new InvalidServiceException('Logger Service must implement'.__NAMESPACE__.'LoggerInterface');
        }
    }
27239
public function logAction($query) {
        $interval = Configure::read('Admin.logActions.interval') ?: '-6 hours';

        $conditions = $query;
        $conditions['created >='] = date('Y-m-d H:i:s', strtotime($interval));

        $count = $this->find('count', array(
            'conditions' => $conditions
        ));

        if ($count) {
            return true;
        }

        $this->create();

        return $this->save($query, false);
    }
290555
final public function handle(QueryInterface $query)
    {
        $result = $this->process($query);

        if ($result === null && $this->successor !== null) {
            $result = $this->successor->handle($query);
        }

        return $result;
    }
736035
public function log(RequestInterface $request = null, User $user = null)
    {
        if ($request === null) {
            $request = ServerRequest::fromGlobals();
        }

        if ($user === null) {
            $user = \common_session_SessionManager::getSession()->getUser();
        }
       return  $this->getStorage()->log($request, $user);
    }
26228
public function apply($builder, QueryInterface $query): void
    {
        // Apply joins
        foreach ($query->getJoins() as $join) {
            if ($join->isInner()) {
                $builder->innerJoin($join->getFromAlias(), $join->getTo(), $join->getToAlias(), $join->getCondition());
            } else {
                $builder->leftJoin($join->getFromAlias(), $join->getTo(), $join->getToAlias(), $join->getCondition());
            }
        }

        // Apply rules
        foreach ($query->getRules() as $rule) {
            $builder->andWhere($rule->getRule());
        }

        // Apply parameters
        foreach ($query->getParameters() as $parameter) {
            $builder->setParameter($parameter->getName(), $parameter->getValue(), $parameter->getType());
        }

        // Apply orders
        foreach ($query->getOrders() as $order) {
            $builder->addOrderBy($order->getField(), $order->getDirection());
        }
    }
1290532
protected function addDateFilterToQuery(Query $query, DateTimeInterface $dateTime): void
    {
        $boolQuery = $this->getBoolQuery($query);

        $formattedDate = $dateTime->format('Y-m-d H:i:s');

        $rangeStart = $this->getFactory()->createQueryBuilder()->createRangeQuery(PageIndexMap::STARTAT, null, $formattedDate);
        $boolQuery->addFilter($rangeStart);

        $rangeEnd = $this->getFactory()->createQueryBuilder()->createRangeQuery(PageIndexMap::ENDAT, $formattedDate, null);
        $boolQuery->addFilter($rangeEnd);
    }
92582
public function setLogger(LoggerInterface $logger)
    {
        $this->v8->logger = $logger;
        $this->v8->executeString(
            'jsHb.log = function(level, message) {
                phpHb.logger.log(level, message)
            }',
            __CLASS__ . '::' . __METHOD__ . '()'
        );
    }
274879
public function onLogQuery(callable $callback = null)
    {
        if ($callback === null || is_callable($callback)) {
            $this->on_log_query = $callback;
        } else {
            throw new InvalidArgumentException('Callback needs to be NULL or callable');
        }
    }
527211
public function enableQueryLog() {
		$this->loggingQueries = true;

		if ( ! $this->logger ) {
			$this->setLogger( new QueryLogger );
		}

		return $this;
	}