mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-24 07:42:40 +01:00
dc6c1bf435
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
41 lines
1,015 B
PHP
41 lines
1,015 B
PHP
<?php
|
|
|
|
final class PhabricatorAccessLog {
|
|
|
|
static $log;
|
|
|
|
public static function init() {
|
|
// NOTE: This currently has no effect, but some day we may reuse PHP
|
|
// interpreters to run multiple requests. If we do, it has the effect of
|
|
// throwing away the old log.
|
|
self::$log = null;
|
|
}
|
|
|
|
public static function getLog() {
|
|
if (!self::$log) {
|
|
$path = PhabricatorEnv::getEnvConfig('log.access.path');
|
|
$format = PhabricatorEnv::getEnvConfig('log.access.format');
|
|
$format = nonempty(
|
|
$format,
|
|
"[%D]\t%p\t%h\t%r\t%u\t%C\t%m\t%U\t%R\t%c\t%T");
|
|
|
|
// NOTE: Path may be null. We still create the log, it just won't write
|
|
// anywhere.
|
|
|
|
$log = id(new PhutilDeferredLog($path, $format))
|
|
->setFailQuietly(true)
|
|
->setData(
|
|
array(
|
|
'D' => date('r'),
|
|
'h' => php_uname('n'),
|
|
'p' => getmypid(),
|
|
'e' => time(),
|
|
));
|
|
|
|
self::$log = $log;
|
|
}
|
|
|
|
return self::$log;
|
|
}
|
|
|
|
}
|