1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Fail quietly when failing to write access log

Summary: See D5874. PhutilDeferredLog's exception on `write()`/`__destruct()` is not especially important and can come at an awkward time. Instead of throwing, just emit an error message to the log.

Test Plan: Faked failed writes and saw an error message in the log instead of many terrible things everywhere.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3144

Differential Revision: https://secure.phabricator.com/D5875
This commit is contained in:
epriestley 2013-05-09 16:08:26 -07:00
parent 83109ff8af
commit dc6c1bf435
2 changed files with 14 additions and 18 deletions

View file

@ -22,14 +22,15 @@ final class PhabricatorAccessLog {
// NOTE: Path may be null. We still create the log, it just won't write
// anywhere.
$log = new PhutilDeferredLog($path, $format);
$log->setData(
array(
'D' => date('r'),
'h' => php_uname('n'),
'p' => getmypid(),
'e' => time(),
));
$log = id(new PhutilDeferredLog($path, $format))
->setFailQuietly(true)
->setData(
array(
'D' => date('r'),
'h' => php_uname('n'),
'p' => getmypid(),
'e' => time(),
));
self::$log = $log;
}

View file

@ -194,16 +194,11 @@ final class PhabricatorStartup {
if ($access_log) {
// We may end up here before the access log is initialized, e.g. from
// verifyPHP().
try {
$access_log->setData(
array(
'c' => 500,
));
$access_log->write();
} catch (Exception $ex) {
$message .= "\n(Moreover, unable to write to access log.)";
}
$access_log->setData(
array(
'c' => 500,
));
$access_log->write();
}
header(