Skip to content

Commit 443a2c9

Browse files
committed
显示当前查询的数据库
1 parent fb65b0d commit 443a2c9

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/ServiceProvider.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ public function boot()
3535
$sqlWithPlaceholders = str_replace(['%', '?'], ['%%', '%s'], $query->sql);
3636

3737
$bindings = $query->connection->prepareBindings($query->bindings);
38-
$pdo = $query->connection->getPdo();
39-
$realSql = $sqlWithPlaceholders;
38+
$pdo = $query->connection->getPdo();
39+
$realSql = $sqlWithPlaceholders;
4040
$duration = $this->formatDuration($query->time / 1000);
4141

4242
if (count($bindings) > 0) {
4343
$realSql = vsprintf($sqlWithPlaceholders, array_map([$pdo, 'quote'], $bindings));
4444
}
45-
46-
Log::debug(sprintf('[%s] %s | %s: %s', $duration, $realSql, request()->method(), request()->getRequestUri()));
45+
Log::debug(sprintf('[%s] [%s] %s | %s: %s', $query->connection->getDatabaseName(), $duration, $realSql, request()->method(), request()->getRequestUri()));
4746
});
4847
}
4948

@@ -64,11 +63,11 @@ public function register()
6463
private function formatDuration($seconds)
6564
{
6665
if ($seconds < 0.001) {
67-
return round($seconds * 1000000).'μs';
66+
return round($seconds * 1000000) . 'μs';
6867
} elseif ($seconds < 1) {
69-
return round($seconds * 1000, 2).'ms';
68+
return round($seconds * 1000, 2) . 'ms';
7069
}
7170

72-
return round($seconds, 2).'s';
71+
return round($seconds, 2) . 's';
7372
}
7473
}

0 commit comments

Comments
 (0)