Changeset View
Changeset View
Standalone View
Standalone View
src/serviceprofiler/PhutilServiceProfiler.php
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | if ($is_begin) { | ||||
if (isset($data['proxy'])) { | if (isset($data['proxy'])) { | ||||
$proxy = phutil_censor_credentials($data['proxy']); | $proxy = phutil_censor_credentials($data['proxy']); | ||||
} else { | } else { | ||||
$proxy = null; | $proxy = null; | ||||
} | } | ||||
$uri = phutil_censor_credentials($data['uri']); | $uri = phutil_censor_credentials($data['uri']); | ||||
if (strlen($proxy)) { | if ($proxy !== null) { | ||||
$desc = "{$proxy} >> {$uri}"; | $desc = "{$proxy} >> {$uri}"; | ||||
} else { | } else { | ||||
$desc = $uri; | $desc = $uri; | ||||
} | } | ||||
break; | break; | ||||
case 'lint': | case 'lint': | ||||
$desc = $data['linter']; | $desc = $data['linter']; | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | $console->writeLog( | ||||
$mark, | $mark, | ||||
$id, | $id, | ||||
pht('%s', new PhutilNumber((int)(1000 * $elapsed))), | pht('%s', new PhutilNumber((int)(1000 * $elapsed))), | ||||
$type, | $type, | ||||
self::escapeProfilerStringForDisplay($desc)); | self::escapeProfilerStringForDisplay($desc)); | ||||
} | } | ||||
private static function escapeProfilerStringForDisplay($string) { | private static function escapeProfilerStringForDisplay($string) { | ||||
if ($string === null) { | |||||
return ''; | |||||
} | |||||
// Convert tabs and newlines to spaces and collapse blocks of whitespace, | // Convert tabs and newlines to spaces and collapse blocks of whitespace, | ||||
// most often formatting in queries. | // most often formatting in queries. | ||||
$string = preg_replace('/\s{2,}/', ' ', $string); | $string = preg_replace('/\s{2,}/', ' ', $string); | ||||
// Replace sequences of binary characters with printable text. We allow | // Replace sequences of binary characters with printable text. We allow | ||||
// some printable characters to appear in between unprintable characters | // some printable characters to appear in between unprintable characters | ||||
// to try to collapse the entire run. | // to try to collapse the entire run. | ||||
$string = preg_replace( | $string = preg_replace( | ||||
Show All 9 Lines |