Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/option/PhabricatorAccessLogConfigOptions.php
| <?php | <?php | ||||
| final class PhabricatorAccessLogConfigOptions | final class PhabricatorAccessLogConfigOptions | ||||
| extends PhabricatorApplicationConfigOptions { | extends PhabricatorApplicationConfigOptions { | ||||
| public function getName() { | public function getName() { | ||||
| return pht("Access Logs"); | return pht('Access Logs'); | ||||
| } | } | ||||
| public function getDescription() { | public function getDescription() { | ||||
| return pht("Configure the access logs, which log HTTP/SSH requests."); | return pht('Configure the access logs, which log HTTP/SSH requests.'); | ||||
| } | } | ||||
| public function getOptions() { | public function getOptions() { | ||||
| $common_map = array( | $common_map = array( | ||||
| 'C' => pht("The controller or workflow which handled the request."), | 'C' => pht('The controller or workflow which handled the request.'), | ||||
| 'c' => pht("The HTTP response code or process exit code."), | 'c' => pht('The HTTP response code or process exit code.'), | ||||
| 'D' => pht("The request date."), | 'D' => pht('The request date.'), | ||||
| 'e' => pht("Epoch timestamp."), | 'e' => pht('Epoch timestamp.'), | ||||
| 'h' => pht("The webserver's host name."), | 'h' => pht("The webserver's host name."), | ||||
| 'p' => pht("The PID of the server process."), | 'p' => pht('The PID of the server process.'), | ||||
| 'r' => pht("The remote IP."), | 'r' => pht('The remote IP.'), | ||||
| 'T' => pht("The request duration, in microseconds."), | 'T' => pht('The request duration, in microseconds.'), | ||||
| 'U' => pht("The request path, or request target."), | 'U' => pht('The request path, or request target.'), | ||||
| 'm' => pht("For conduit, the Conduit method which was invoked."), | 'm' => pht('For conduit, the Conduit method which was invoked.'), | ||||
| 'u' => pht("The logged-in username, if one is logged in."), | 'u' => pht('The logged-in username, if one is logged in.'), | ||||
| 'P' => pht("The logged-in user PHID, if one is logged in."), | 'P' => pht('The logged-in user PHID, if one is logged in.'), | ||||
| 'i' => pht("Request input, in bytes."), | 'i' => pht('Request input, in bytes.'), | ||||
| 'o' => pht("Request output, in bytes."), | 'o' => pht('Request output, in bytes.'), | ||||
| ); | ); | ||||
| $http_map = $common_map + array( | $http_map = $common_map + array( | ||||
| 'R' => pht("The HTTP referrer."), | 'R' => pht('The HTTP referrer.'), | ||||
| 'M' => pht("The HTTP method."), | 'M' => pht('The HTTP method.'), | ||||
| ); | ); | ||||
| $ssh_map = $common_map + array( | $ssh_map = $common_map + array( | ||||
| 's' => pht("The system user."), | 's' => pht('The system user.'), | ||||
| 'S' => pht("The system sudo user."), | 'S' => pht('The system sudo user.'), | ||||
| ); | ); | ||||
| $http_desc = pht( | $http_desc = pht( | ||||
| "Format for the HTTP access log. Use {{log.access.path}} to set the ". | 'Format for the HTTP access log. Use {{log.access.path}} to set the '. | ||||
| "path. Available variables are:"); | 'path. Available variables are:'); | ||||
| $http_desc .= "\n\n"; | $http_desc .= "\n\n"; | ||||
| $http_desc .= $this->renderMapHelp($http_map); | $http_desc .= $this->renderMapHelp($http_map); | ||||
| $ssh_desc = pht( | $ssh_desc = pht( | ||||
| "Format for the SSH access log. Use {{log.ssh.path}} to set the ". | 'Format for the SSH access log. Use {{log.ssh.path}} to set the '. | ||||
| "path. Available variables are:"); | 'path. Available variables are:'); | ||||
| $ssh_desc .= "\n\n"; | $ssh_desc .= "\n\n"; | ||||
| $ssh_desc .= $this->renderMapHelp($ssh_map); | $ssh_desc .= $this->renderMapHelp($ssh_map); | ||||
| return array( | return array( | ||||
| $this->newOption('log.access.path', 'string', null) | $this->newOption('log.access.path', 'string', null) | ||||
| ->setLocked(true) | ->setLocked(true) | ||||
| ->setSummary(pht("Access log location.")) | ->setSummary(pht('Access log location.')) | ||||
| ->setDescription( | ->setDescription( | ||||
| pht( | pht( | ||||
| "To enable the Phabricator access log, specify a path. The ". | "To enable the Phabricator access log, specify a path. The ". | ||||
| "access log can provide more detailed information about ". | "access log can provide more detailed information about ". | ||||
| "Phabricator access than normal HTTP access logs (for instance, ". | "Phabricator access than normal HTTP access logs (for instance, ". | ||||
| "it can show logged-in users, controllers, and other application ". | "it can show logged-in users, controllers, and other application ". | ||||
| "data).\n\n". | "data).\n\n". | ||||
| "If not set, no log will be written.")) | "If not set, no log will be written.")) | ||||
| ->addExample( | ->addExample( | ||||
| null, | null, | ||||
| pht('Disable access log.')) | pht('Disable access log.')) | ||||
| ->addExample( | ->addExample( | ||||
| '/var/log/phabricator/access.log', | '/var/log/phabricator/access.log', | ||||
| pht('Write access log here.')), | pht('Write access log here.')), | ||||
| $this->newOption( | $this->newOption( | ||||
| 'log.access.format', | 'log.access.format', | ||||
| // NOTE: This is 'wild' intead of 'string' so "\t" and such can be | // NOTE: This is 'wild' intead of 'string' so "\t" and such can be | ||||
| // specified. | // specified. | ||||
| 'wild', | 'wild', | ||||
| "[%D]\t%p\t%h\t%r\t%u\t%C\t%m\t%U\t%R\t%c\t%T") | "[%D]\t%p\t%h\t%r\t%u\t%C\t%m\t%U\t%R\t%c\t%T") | ||||
| ->setLocked(true) | ->setLocked(true) | ||||
| ->setSummary(pht("Access log format.")) | ->setSummary(pht('Access log format.')) | ||||
| ->setDescription($http_desc), | ->setDescription($http_desc), | ||||
| $this->newOption('log.ssh.path', 'string', null) | $this->newOption('log.ssh.path', 'string', null) | ||||
| ->setLocked(true) | ->setLocked(true) | ||||
| ->setSummary(pht("SSH log location.")) | ->setSummary(pht('SSH log location.')) | ||||
| ->setDescription( | ->setDescription( | ||||
| pht( | pht( | ||||
| "To enable the Phabricator SSH log, specify a path. The ". | "To enable the Phabricator SSH log, specify a path. The ". | ||||
| "access log can provide more detailed information about SSH ". | "access log can provide more detailed information about SSH ". | ||||
| "access than a normal SSH log (for instance, it can show ". | "access than a normal SSH log (for instance, it can show ". | ||||
| "logged-in users, commands, and other application data).\n\n". | "logged-in users, commands, and other application data).\n\n". | ||||
| "If not set, no log will be written.")) | "If not set, no log will be written.")) | ||||
| ->addExample( | ->addExample( | ||||
| null, | null, | ||||
| pht('Disable SSH log.')) | pht('Disable SSH log.')) | ||||
| ->addExample( | ->addExample( | ||||
| '/var/log/phabricator/ssh.log', | '/var/log/phabricator/ssh.log', | ||||
| pht('Write SSH log here.')), | pht('Write SSH log here.')), | ||||
| $this->newOption( | $this->newOption( | ||||
| 'log.ssh.format', | 'log.ssh.format', | ||||
| 'wild', | 'wild', | ||||
| "[%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") | "[%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") | ||||
| ->setLocked(true) | ->setLocked(true) | ||||
| ->setSummary(pht("SSH log format.")) | ->setSummary(pht('SSH log format.')) | ||||
| ->setDescription($ssh_desc), | ->setDescription($ssh_desc), | ||||
| ); | ); | ||||
| } | } | ||||
| private function renderMapHelp(array $map) { | private function renderMapHelp(array $map) { | ||||
| $desc = ''; | $desc = ''; | ||||
| foreach ($map as $key => $kdesc) { | foreach ($map as $key => $kdesc) { | ||||
| $desc .= " - `%".$key."` ".$kdesc."\n"; | $desc .= " - `%".$key."` ".$kdesc."\n"; | ||||
| Show All 15 Lines | |||||