Remove product literal strings in "pht()", part 18
[phabricator.git] / src / infrastructure / log / PhabricatorSSHLog.php
blobde4c270f72e81b0844f70f6f3f30b7c55966fa8a
1 <?php
3 final class PhabricatorSSHLog extends Phobject {
5 private static $log;
7 public static function getLog() {
8 if (!self::$log) {
9 $path = PhabricatorEnv::getEnvConfig('log.ssh.path');
10 $format = PhabricatorEnv::getEnvConfig('log.ssh.format');
11 $format = nonempty(
12 $format,
13 "[%D]\t%p\t%h\t%r\t%s\t%S\t%u\t%C\t%U\t%c\t%T\t%i\t%o");
15 // NOTE: Path may be null. We still create the log, it just won't write
16 // anywhere.
18 $data = array(
19 'D' => date('r'),
20 'h' => php_uname('n'),
21 'p' => getmypid(),
22 'e' => time(),
23 'I' => PhabricatorEnv::getEnvConfig('cluster.instance'),
26 $sudo_user = PhabricatorEnv::getEnvConfig('phd.user');
27 if (strlen($sudo_user)) {
28 $data['S'] = $sudo_user;
31 if (function_exists('posix_geteuid')) {
32 $system_uid = posix_geteuid();
33 $system_info = posix_getpwuid($system_uid);
34 $data['s'] = idx($system_info, 'name');
37 $client = getenv('SSH_CLIENT');
38 if (strlen($client)) {
39 $remote_address = head(explode(' ', $client));
40 $data['r'] = $remote_address;
43 $log = id(new PhutilDeferredLog($path, $format))
44 ->setFailQuietly(true)
45 ->setData($data);
47 self::$log = $log;
50 return self::$log;