Path: blob/master/src/applications/config/option/PhabricatorAccessLogConfigOptions.php
12256 views
<?php12final class PhabricatorAccessLogConfigOptions3extends PhabricatorApplicationConfigOptions {45public function getName() {6return pht('Access Logs');7}89public function getDescription() {10return pht('Configure the access logs, which log HTTP/SSH requests.');11}1213public function getIcon() {14return 'fa-list';15}1617public function getGroup() {18return 'core';19}2021public function getOptions() {22$common_map = array(23'C' => pht('The controller or workflow which handled the request.'),24'c' => pht('The HTTP response code or process exit code.'),25'D' => pht('The request date.'),26'e' => pht('Epoch timestamp.'),27'h' => pht("The webserver's host name."),28'p' => pht('The PID of the server process.'),29'r' => pht('The remote IP.'),30'T' => pht('The request duration, in microseconds.'),31'U' => pht('The request path, or request target.'),32'm' => pht('For conduit, the Conduit method which was invoked.'),33'u' => pht('The logged-in username, if one is logged in.'),34'P' => pht('The logged-in user PHID, if one is logged in.'),35'i' => pht('Request input, in bytes.'),36'o' => pht('Request output, in bytes.'),37'I' => pht('Cluster instance name, if configured.'),38);3940$http_map = $common_map + array(41'R' => pht('The HTTP referrer.'),42'M' => pht('The HTTP method.'),43);4445$ssh_map = $common_map + array(46's' => pht('The system user.'),47'S' => pht('The system sudo user.'),48'k' => pht('ID of the SSH key used to authenticate the request.'),4950// TODO: This is a reasonable thing to support in the HTTP access51// log, too.52'Q' => pht('A random, unique string which identifies the request.'),53);5455$http_desc = pht(56'Format for the HTTP access log. Use `%s` to set the path. '.57'Available variables are:',58'log.access.path');59$http_desc .= "\n\n";60$http_desc .= $this->renderMapHelp($http_map);6162$ssh_desc = pht(63'Format for the SSH access log. Use %s to set the path. '.64'Available variables are:',65'log.ssh.path');66$ssh_desc .= "\n\n";67$ssh_desc .= $this->renderMapHelp($ssh_map);6869return array(70$this->newOption('log.access.path', 'string', null)71->setLocked(true)72->setSummary(pht('Access log location.'))73->setDescription(74pht(75"To enable the HTTP access log, specify a path. This log is ".76"more detailed than normal HTTP access logs (for instance, ".77"it can show logged-in users, controllers, and other application ".78"data).\n\n".79"If not set, no log will be written."))80->addExample(81null,82pht('Disable access log.'))83->addExample(84'/var/log/devtools/access.log',85pht('Write access log here.')),86$this->newOption(87'log.access.format',88// NOTE: This is 'wild' intead of 'string' so "\t" and such can be89// specified.90'wild',91"[%D]\t%p\t%h\t%r\t%u\t%C\t%m\t%U\t%R\t%c\t%T")92->setLocked(true)93->setSummary(pht('Access log format.'))94->setDescription($http_desc),95$this->newOption('log.ssh.path', 'string', null)96->setLocked(true)97->setSummary(pht('SSH log location.'))98->setDescription(99pht(100"To enable the SSH log, specify a path. This log can provide ".101"more detailed information about SSH access than a normal SSH ".102"log (for instance, it can show logged-in users, commands, and ".103"other application data).\n\n".104"If not set, no log will be written."))105->addExample(106null,107pht('Disable SSH log.'))108->addExample(109'/var/log/devtools/ssh.log',110pht('Write SSH log here.')),111$this->newOption(112'log.ssh.format',113'wild',114"[%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")115->setLocked(true)116->setSummary(pht('SSH log format.'))117->setDescription($ssh_desc),118$this->newOption('log.ssh-error.path', 'string', null)119->setLocked(true)120->setSummary(pht('SSH error log location.'))121->setDescription(122pht(123'To enable the SSH error log, specify a path. Errors occurring '.124'in contexts where this software is serving SSH requests '.125'will be written to this log.'.126"\n\n".127'If not set, no log will be written.'))128->addExample(null, pht('Disable SSH error log.'))129->addExample(130'/var/log/devtools/ssh-error.log',131pht('Write SSH error log here.')),132);133}134135private function renderMapHelp(array $map) {136$desc = '';137foreach ($map as $key => $kdesc) {138$desc .= " - `%".$key."` ".$kdesc."\n";139}140$desc .= "\n";141$desc .= pht(142"If a variable isn't available (for example, %%m appears in the file ".143"format but the request is not a Conduit request), it will be rendered ".144"as '-'");145$desc .= "\n\n";146$desc .= pht(147"Note that the default format is subject to change in the future, so ".148"if you rely on the log's format, specify it explicitly.");149150return $desc;151}152153}154155156