2013-01-01 23:09:17 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorAccessLogConfigOptions
|
|
|
|
extends PhabricatorApplicationConfigOptions {
|
|
|
|
|
|
|
|
public function getName() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return pht('Access Logs');
|
2013-01-01 23:09:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return pht('Configure the access logs, which log HTTP/SSH requests.');
|
2013-01-01 23:09:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getOptions() {
|
2013-12-06 02:00:48 +01:00
|
|
|
$common_map = array(
|
2014-06-09 20:36:49 +02:00
|
|
|
'C' => pht('The controller or workflow which handled the request.'),
|
|
|
|
'c' => pht('The HTTP response code or process exit code.'),
|
|
|
|
'D' => pht('The request date.'),
|
|
|
|
'e' => pht('Epoch timestamp.'),
|
2013-01-01 23:09:17 +01:00
|
|
|
'h' => pht("The webserver's host name."),
|
2014-06-09 20:36:49 +02:00
|
|
|
'p' => pht('The PID of the server process.'),
|
|
|
|
'r' => pht('The remote IP.'),
|
|
|
|
'T' => pht('The request duration, in microseconds.'),
|
|
|
|
'U' => pht('The request path, or request target.'),
|
|
|
|
'm' => pht('For conduit, the Conduit method which was invoked.'),
|
|
|
|
'u' => pht('The logged-in username, if one is logged in.'),
|
|
|
|
'P' => pht('The logged-in user PHID, if one is logged in.'),
|
|
|
|
'i' => pht('Request input, in bytes.'),
|
|
|
|
'o' => pht('Request output, in bytes.'),
|
2013-12-06 02:00:48 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$http_map = $common_map + array(
|
2014-06-09 20:36:49 +02:00
|
|
|
'R' => pht('The HTTP referrer.'),
|
|
|
|
'M' => pht('The HTTP method.'),
|
2013-01-01 23:09:17 +01:00
|
|
|
);
|
|
|
|
|
2013-12-06 02:00:48 +01:00
|
|
|
$ssh_map = $common_map + array(
|
2014-06-09 20:36:49 +02:00
|
|
|
's' => pht('The system user.'),
|
|
|
|
'S' => pht('The system sudo user.'),
|
2015-01-28 23:41:24 +01:00
|
|
|
'k' => pht('ID of the SSH key used to authenticate the request.'),
|
2013-12-06 02:00:48 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$http_desc = pht(
|
2014-06-09 20:36:49 +02:00
|
|
|
'Format for the HTTP access log. Use {{log.access.path}} to set the '.
|
|
|
|
'path. Available variables are:');
|
2013-12-06 02:00:48 +01:00
|
|
|
$http_desc .= "\n\n";
|
|
|
|
$http_desc .= $this->renderMapHelp($http_map);
|
|
|
|
|
|
|
|
$ssh_desc = pht(
|
2014-06-09 20:36:49 +02:00
|
|
|
'Format for the SSH access log. Use {{log.ssh.path}} to set the '.
|
|
|
|
'path. Available variables are:');
|
2013-12-06 02:00:48 +01:00
|
|
|
$ssh_desc .= "\n\n";
|
|
|
|
$ssh_desc .= $this->renderMapHelp($ssh_map);
|
2013-01-01 23:09:17 +01:00
|
|
|
|
|
|
|
return array(
|
|
|
|
$this->newOption('log.access.path', 'string', null)
|
2013-12-06 02:00:48 +01:00
|
|
|
->setLocked(true)
|
2014-06-09 20:36:49 +02:00
|
|
|
->setSummary(pht('Access log location.'))
|
2013-01-01 23:09:17 +01:00
|
|
|
->setDescription(
|
|
|
|
pht(
|
|
|
|
"To enable the Phabricator access log, specify a path. The ".
|
|
|
|
"access log can provide more detailed information about ".
|
|
|
|
"Phabricator access than normal HTTP access logs (for instance, ".
|
|
|
|
"it can show logged-in users, controllers, and other application ".
|
|
|
|
"data).\n\n".
|
|
|
|
"If not set, no log will be written."))
|
|
|
|
->addExample(
|
|
|
|
null,
|
2013-12-06 02:00:48 +01:00
|
|
|
pht('Disable access log.'))
|
2013-01-01 23:09:17 +01:00
|
|
|
->addExample(
|
|
|
|
'/var/log/phabricator/access.log',
|
2013-12-06 02:00:48 +01:00
|
|
|
pht('Write access log here.')),
|
2013-01-01 23:09:17 +01:00
|
|
|
$this->newOption(
|
|
|
|
'log.access.format',
|
|
|
|
// NOTE: This is 'wild' intead of 'string' so "\t" and such can be
|
|
|
|
// specified.
|
|
|
|
'wild',
|
|
|
|
"[%D]\t%p\t%h\t%r\t%u\t%C\t%m\t%U\t%R\t%c\t%T")
|
2013-12-06 02:00:48 +01:00
|
|
|
->setLocked(true)
|
2014-06-09 20:36:49 +02:00
|
|
|
->setSummary(pht('Access log format.'))
|
2013-12-06 02:00:48 +01:00
|
|
|
->setDescription($http_desc),
|
|
|
|
$this->newOption('log.ssh.path', 'string', null)
|
|
|
|
->setLocked(true)
|
2014-06-09 20:36:49 +02:00
|
|
|
->setSummary(pht('SSH log location.'))
|
2013-12-06 02:00:48 +01:00
|
|
|
->setDescription(
|
|
|
|
pht(
|
|
|
|
"To enable the Phabricator SSH log, specify a path. The ".
|
|
|
|
"access log can provide more detailed information about SSH ".
|
|
|
|
"access than a normal SSH log (for instance, it can show ".
|
|
|
|
"logged-in users, commands, and other application data).\n\n".
|
|
|
|
"If not set, no log will be written."))
|
|
|
|
->addExample(
|
|
|
|
null,
|
|
|
|
pht('Disable SSH log.'))
|
|
|
|
->addExample(
|
|
|
|
'/var/log/phabricator/ssh.log',
|
|
|
|
pht('Write SSH log here.')),
|
|
|
|
$this->newOption(
|
|
|
|
'log.ssh.format',
|
|
|
|
'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")
|
|
|
|
->setLocked(true)
|
2014-06-09 20:36:49 +02:00
|
|
|
->setSummary(pht('SSH log format.'))
|
2013-12-06 02:00:48 +01:00
|
|
|
->setDescription($ssh_desc),
|
2013-01-01 23:09:17 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-12-06 02:00:48 +01:00
|
|
|
private function renderMapHelp(array $map) {
|
|
|
|
$desc = '';
|
|
|
|
foreach ($map as $key => $kdesc) {
|
|
|
|
$desc .= " - `%".$key."` ".$kdesc."\n";
|
|
|
|
}
|
|
|
|
$desc .= "\n";
|
|
|
|
$desc .= pht(
|
|
|
|
"If a variable isn't available (for example, %%m appears in the file ".
|
|
|
|
"format but the request is not a Conduit request), it will be rendered ".
|
|
|
|
"as '-'");
|
|
|
|
$desc .= "\n\n";
|
|
|
|
$desc .= pht(
|
|
|
|
"Note that the default format is subject to change in the future, so ".
|
|
|
|
"if you rely on the log's format, specify it explicitly.");
|
|
|
|
|
|
|
|
return $desc;
|
|
|
|
}
|
|
|
|
|
2013-01-01 23:09:17 +01:00
|
|
|
}
|