Remove product literal strings in "pht()", part 18
[phabricator.git] / src / infrastructure / log / PhabricatorAccessLog.php
blob2ffa0577a82858e0460507f4a617a5c33c1d77b2
1 <?php
3 final class PhabricatorAccessLog extends Phobject {
5 private static $log;
7 public static function init() {
8 // NOTE: This currently has no effect, but some day we may reuse PHP
9 // interpreters to run multiple requests. If we do, it has the effect of
10 // throwing away the old log.
11 self::$log = null;
14 public static function getLog() {
15 if (!self::$log) {
16 $path = PhabricatorEnv::getEnvConfig('log.access.path');
17 $format = PhabricatorEnv::getEnvConfig('log.access.format');
18 $format = nonempty(
19 $format,
20 "[%D]\t%p\t%h\t%r\t%u\t%C\t%m\t%U\t%R\t%c\t%T");
22 // NOTE: Path may be null. We still create the log, it just won't write
23 // anywhere.
25 $log = id(new PhutilDeferredLog($path, $format))
26 ->setFailQuietly(true)
27 ->setData(
28 array(
29 'D' => date('r'),
30 'h' => php_uname('n'),
31 'p' => getmypid(),
32 'e' => time(),
33 'I' => PhabricatorEnv::getEnvConfig('cluster.instance'),
34 ));
36 self::$log = $log;
39 return self::$log;