Illuminate\Database\Connection::enableQueryLog PHP Метод

enableQueryLog() публичный Метод

Enable the query log on the connection.
public enableQueryLog ( ) : void
Результат void
    public function enableQueryLog()
    {
        $this->loggingQueries = true;
    }

Usage Example

Пример #1
0
 protected function startQueryLog()
 {
     $this->logFile = $this->tmpDir->getTempDir('logs') . '/query.log';
     @unlink($this->logFile);
     $this->connection->enableQueryLog();
     $this->logger->pushHandler(new StreamHandler($this->logFile, LoggerEx::INFO));
     $this->dispatcher->listen(QueryExecuted::class, function (QueryExecuted $query) {
         $sql = preg_replace_callback('/\\?/', function () use($query, &$index) {
             return sprintf("'%s'", $query->bindings[$index++ ?? 0]);
         }, $query->sql);
         $this->logger->info($sql);
     });
 }