@@ -4,48 +4,56 @@ final class PhabricatorAccessLogConfigOptions
4
4
extends PhabricatorApplicationConfigOptions {
5
5
6
6
public function getName () {
7
- return pht ("Access Log " );
7
+ return pht ("Access Logs " );
8
8
}
9
9
10
10
public function getDescription () {
11
- return pht ("Configure the access log , which logs all requests. " );
11
+ return pht ("Configure the access logs , which log HTTP/SSH requests. " );
12
12
}
13
13
14
14
public function getOptions () {
15
- $ map = array (
16
- 'c ' => pht ("The HTTP response code . " ),
17
- 'C ' => pht ("The controller which handled the request . " ),
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
18
'D ' => pht ("The request date. " ),
19
19
'e ' => pht ("Epoch timestamp. " ),
20
20
'h ' => pht ("The webserver's host name. " ),
21
21
'p ' => pht ("The PID of the server process. " ),
22
- 'R ' => pht ("The HTTP referrer. " ),
23
22
'r ' => pht ("The remote IP. " ),
24
23
'T ' => pht ("The request duration, in microseconds. " ),
25
- 'U ' => pht ("The request path. " ),
24
+ 'U ' => pht ("The request path, or request target. " ),
25
+ 'm ' => pht ("For conduit, the Conduit method which was invoked. " ),
26
26
'u ' => pht ("The logged-in username, if one is logged in. " ),
27
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. " ),
28
34
'M ' => pht ("The HTTP method. " ),
29
- 'm ' => pht ("For conduit, the Conduit method which was invoked. " ),
30
35
);
31
36
32
- $ fdesc = pht ("Format for the access log. Available variables are: " );
33
- $ fdesc .= "\n\n" ;
34
- foreach ($ map as $ key => $ desc ) {
35
- $ fdesc .= " - % " .$ key ." " .$ desc ."\n" ;
36
- }
37
- $ fdesc .= "\n" ;
38
- $ fdesc .= pht (
39
- "If a variable isn't available (for example, %%m appears in the file " .
40
- "format but the request is not a Conduit request), it will be rendered " .
41
- "as '-' " );
42
- $ fdesc .= "\n\n" ;
43
- $ fdesc .= pht (
44
- "Note that the default format is subject to change in the future, so " .
45
- "if you rely on the log's format, specify it explicitly. " );
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 );
46
53
47
54
return array (
48
55
$ this ->newOption ('log.access.path ' , 'string ' , null )
56
+ ->setLocked (true )
49
57
->setSummary (pht ("Access log location. " ))
50
58
->setDescription (
51
59
pht (
@@ -57,19 +65,61 @@ public function getOptions() {
57
65
"If not set, no log will be written. " ))
58
66
->addExample (
59
67
null ,
60
- pht ('Disable access log ' ))
68
+ pht ('Disable access log. ' ))
61
69
->addExample (
62
70
'/var/log/phabricator/access.log ' ,
63
- pht ('Write access log here ' )),
71
+ pht ('Write access log here. ' )),
64
72
$ this ->newOption (
65
73
'log.access.format ' ,
66
74
// NOTE: This is 'wild' intead of 'string' so "\t" and such can be
67
75
// specified.
68
76
'wild ' ,
69
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 )
70
79
->setSummary (pht ("Access log format. " ))
71
- ->setDescription ($ fdesc ),
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 ),
72
104
);
73
105
}
74
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
+
75
125
}
0 commit comments