@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 42 lines 1.1 kB view raw
1<?php 2 3final class PhabricatorAccessLog extends Phobject { 4 5 private static $log; 6 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; 12 } 13 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"); 21 22 // NOTE: Path may be null. We still create the log, it just won't write 23 // anywhere. 24 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 )); 35 36 self::$log = $log; 37 } 38 39 return self::$log; 40 } 41 42}