@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 53 lines 1.4 kB view raw
1<?php 2 3final class PhabricatorSSHLog extends Phobject { 4 5 private static $log; 6 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"); 14 15 // NOTE: Path may be null. We still create the log, it just won't write 16 // anywhere. 17 18 $data = array( 19 'D' => date('r'), 20 'h' => php_uname('n'), 21 'p' => getmypid(), 22 'e' => time(), 23 'I' => PhabricatorEnv::getEnvConfig('cluster.instance'), 24 ); 25 26 $sudo_user = PhabricatorEnv::getEnvConfig('phd.user'); 27 if (phutil_nonempty_string($sudo_user)) { 28 $data['S'] = $sudo_user; 29 } 30 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'); 35 } 36 37 $client = getenv('SSH_CLIENT'); 38 if ($client && strlen($client)) { 39 $remote_address = head(explode(' ', $client)); 40 $data['r'] = $remote_address; 41 } 42 43 $log = id(new PhutilDeferredLog($path, $format)) 44 ->setFailQuietly(true) 45 ->setData($data); 46 47 self::$log = $log; 48 } 49 50 return self::$log; 51 } 52 53}