Skip to content

Commit

Permalink
Allow dbLogQueries option to be int.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Sep 19, 2023
1 parent 7d44bd8 commit af27137
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/dbl.php
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,10 @@ static function log_queries($limit, $file = null) {
self::$verbose = true;
return;
}
if (!is_float($limit)) {
$limit = $limit === true ? 1.0 : 0.0;
if (is_bool($limit)) {
$limit = $limit ? 1.0 : 0.0;
} else if (!is_float($limit)) {
$limit = (float) $limit;
}
if ($limit <= 0
|| ($limit < 1 && mt_rand() < $limit * mt_getrandmax())) {
Expand All @@ -910,7 +912,7 @@ static function shutdown() {
$qlog = "";
foreach (self::$query_log as $where => $what) {
$a = [$what[0], $what[1], $what[2], $where];
$qlog .= "query_log: $self #$i/$n: " . json_encode($a) . "\n";
$qlog .= "query_log: {$self} #{$i}/{$n}: " . json_encode($a) . "\n";
++$i;
$t[0] += $what[0];
$t[1] += $what[1];
Expand Down

0 comments on commit af27137

Please sign in to comment.