Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/log/PhabricatorAccessLog.php
12241 views
1
<?php
2
3
final 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
}
43
44