[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/config/option/ -> PhabricatorAccessLogConfigOptions.php (source)

   1  <?php
   2  
   3  final class PhabricatorAccessLogConfigOptions
   4    extends PhabricatorApplicationConfigOptions {
   5  
   6    public function getName() {
   7      return pht('Access Logs');
   8    }
   9  
  10    public function getDescription() {
  11      return pht('Configure the access logs, which log HTTP/SSH requests.');
  12    }
  13  
  14    public function getOptions() {
  15      $common_map = array(
  16        'C' => pht('The controller or workflow which handled the request.'),
  17        'c' => pht('The HTTP response code or process exit code.'),
  18        'D' => pht('The request date.'),
  19        'e' => pht('Epoch timestamp.'),
  20        'h' => pht("The webserver's host name."),
  21        'p' => pht('The PID of the server process.'),
  22        'r' => pht('The remote IP.'),
  23        'T' => pht('The request duration, in microseconds.'),
  24        'U' => pht('The request path, or request target.'),
  25        'm' => pht('For conduit, the Conduit method which was invoked.'),
  26        'u' => pht('The logged-in username, if one is logged in.'),
  27        'P' => pht('The logged-in user PHID, if one is logged in.'),
  28        'i' => pht('Request input, in bytes.'),
  29        'o' => pht('Request output, in bytes.'),
  30      );
  31  
  32      $http_map = $common_map + array(
  33        'R' => pht('The HTTP referrer.'),
  34        'M' => pht('The HTTP method.'),
  35      );
  36  
  37      $ssh_map = $common_map + array(
  38        's' => pht('The system user.'),
  39        'S' => pht('The system sudo user.'),
  40      );
  41  
  42      $http_desc = pht(
  43        'Format for the HTTP access log. Use {{log.access.path}} to set the '.
  44        'path. Available variables are:');
  45      $http_desc .= "\n\n";
  46      $http_desc .= $this->renderMapHelp($http_map);
  47  
  48      $ssh_desc = pht(
  49        'Format for the SSH access log. Use {{log.ssh.path}} to set the '.
  50        'path. Available variables are:');
  51      $ssh_desc .= "\n\n";
  52      $ssh_desc .= $this->renderMapHelp($ssh_map);
  53  
  54      return array(
  55        $this->newOption('log.access.path', 'string', null)
  56          ->setLocked(true)
  57          ->setSummary(pht('Access log location.'))
  58          ->setDescription(
  59            pht(
  60              "To enable the Phabricator access log, specify a path. The ".
  61              "access log can provide more detailed information about ".
  62              "Phabricator access than normal HTTP access logs (for instance, ".
  63              "it can show logged-in users, controllers, and other application ".
  64              "data).\n\n".
  65              "If not set, no log will be written."))
  66          ->addExample(
  67            null,
  68            pht('Disable access log.'))
  69          ->addExample(
  70            '/var/log/phabricator/access.log',
  71            pht('Write access log here.')),
  72        $this->newOption(
  73          'log.access.format',
  74          // NOTE: This is 'wild' intead of 'string' so "\t" and such can be
  75          // specified.
  76          'wild',
  77          "[%D]\t%p\t%h\t%r\t%u\t%C\t%m\t%U\t%R\t%c\t%T")
  78          ->setLocked(true)
  79          ->setSummary(pht('Access log format.'))
  80          ->setDescription($http_desc),
  81        $this->newOption('log.ssh.path', 'string', null)
  82          ->setLocked(true)
  83          ->setSummary(pht('SSH log location.'))
  84          ->setDescription(
  85            pht(
  86              "To enable the Phabricator SSH log, specify a path. The ".
  87              "access log can provide more detailed information about SSH ".
  88              "access than a normal SSH log (for instance, it can show ".
  89              "logged-in users, commands, and other application data).\n\n".
  90              "If not set, no log will be written."))
  91          ->addExample(
  92            null,
  93            pht('Disable SSH log.'))
  94          ->addExample(
  95            '/var/log/phabricator/ssh.log',
  96            pht('Write SSH log here.')),
  97        $this->newOption(
  98          'log.ssh.format',
  99          'wild',
 100          "[%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")
 101          ->setLocked(true)
 102          ->setSummary(pht('SSH log format.'))
 103          ->setDescription($ssh_desc),
 104      );
 105    }
 106  
 107    private function renderMapHelp(array $map) {
 108      $desc = '';
 109      foreach ($map as $key => $kdesc) {
 110        $desc .= "  - `%".$key."` ".$kdesc."\n";
 111      }
 112      $desc .= "\n";
 113      $desc .= pht(
 114        "If a variable isn't available (for example, %%m appears in the file ".
 115        "format but the request is not a Conduit request), it will be rendered ".
 116        "as '-'");
 117      $desc .= "\n\n";
 118      $desc .= pht(
 119        "Note that the default format is subject to change in the future, so ".
 120        "if you rely on the log's format, specify it explicitly.");
 121  
 122      return $desc;
 123    }
 124  
 125  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1