comparison src/http/ngx_http_log_handler.c @ 210:00cafae0bdf1

nginx-0.0.1-2003-12-14-23:10:27 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 14 Dec 2003 20:10:27 +0000
parents 0b67be7d4489
children 5adc2b75f8a5
comparison
equal deleted inserted replaced
209:e1c815be05ae 210:00cafae0bdf1
17 uintptr_t data); 17 uintptr_t data);
18 static char *ngx_http_log_status(ngx_http_request_t *r, char *buf, 18 static char *ngx_http_log_status(ngx_http_request_t *r, char *buf,
19 uintptr_t data); 19 uintptr_t data);
20 static char *ngx_http_log_length(ngx_http_request_t *r, char *buf, 20 static char *ngx_http_log_length(ngx_http_request_t *r, char *buf,
21 uintptr_t data); 21 uintptr_t data);
22 static char *ngx_http_log_apache_length(ngx_http_request_t *r, char *buf,
23 uintptr_t data);
22 static char *ngx_http_log_header_in(ngx_http_request_t *r, char *buf, 24 static char *ngx_http_log_header_in(ngx_http_request_t *r, char *buf,
23 uintptr_t data); 25 uintptr_t data);
24 static char *ngx_http_log_connection_header_out(ngx_http_request_t *r, 26 static char *ngx_http_log_connection_header_out(ngx_http_request_t *r,
25 char *buf, uintptr_t data); 27 char *buf, uintptr_t data);
26 static char *ngx_http_log_transfer_encoding_header_out(ngx_http_request_t *r, 28 static char *ngx_http_log_transfer_encoding_header_out(ngx_http_request_t *r,
95 97
96 static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", 98 static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
97 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; 99 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
98 100
99 static ngx_str_t ngx_http_combined_fmt = 101 static ngx_str_t ngx_http_combined_fmt =
100 ngx_string("%addr - - [%time] \"%request\" %status %length " 102 ngx_string("%addr - - [%time] \"%request\" %status %apache_length "
101 "\"%{Referer}i\" %{User-Agent}i\""); 103 "\"%{Referer}i\" %{User-Agent}i\"");
102 104
103 105
104 ngx_http_log_op_name_t ngx_http_log_fmt_ops[] = { 106 ngx_http_log_op_name_t ngx_http_log_fmt_ops[] = {
105 { ngx_string("addr"), INET_ADDRSTRLEN - 1, ngx_http_log_addr }, 107 { ngx_string("addr"), INET_ADDRSTRLEN - 1, ngx_http_log_addr },
108 { ngx_string("time"), sizeof("28/Sep/1970:12:00:00") - 1, 110 { ngx_string("time"), sizeof("28/Sep/1970:12:00:00") - 1,
109 ngx_http_log_time }, 111 ngx_http_log_time },
110 { ngx_string("request"), 0, ngx_http_log_request }, 112 { ngx_string("request"), 0, ngx_http_log_request },
111 { ngx_string("status"), 3, ngx_http_log_status }, 113 { ngx_string("status"), 3, ngx_http_log_status },
112 { ngx_string("length"), NGX_OFF_T_LEN, ngx_http_log_length }, 114 { ngx_string("length"), NGX_OFF_T_LEN, ngx_http_log_length },
115 { ngx_string("apache_length"), NGX_OFF_T_LEN, ngx_http_log_apache_length },
113 { ngx_string("i"), NGX_HTTP_LOG_ARG, ngx_http_log_header_in }, 116 { ngx_string("i"), NGX_HTTP_LOG_ARG, ngx_http_log_header_in },
114 { ngx_string("o"), NGX_HTTP_LOG_ARG, ngx_http_log_header_out }, 117 { ngx_string("o"), NGX_HTTP_LOG_ARG, ngx_http_log_header_out },
115 { ngx_null_string, 0, NULL } 118 { ngx_null_string, 0, NULL }
116 }; 119 };
117 120
127 ngx_http_log_loc_conf_t *lcf; 130 ngx_http_log_loc_conf_t *lcf;
128 #if (WIN32) 131 #if (WIN32)
129 u_int written; 132 u_int written;
130 #endif 133 #endif
131 134
132 ngx_log_debug(r->connection->log, "log handler"); 135 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
136 "http log handler");
133 137
134 lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module); 138 lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module);
135 139
136 log = lcf->logs->elts; 140 log = lcf->logs->elts;
137 for (l = 0; l < lcf->logs->nelts; l++) { 141 for (l = 0; l < lcf->logs->nelts; l++) {
243 static char *ngx_http_log_length(ngx_http_request_t *r, char *buf, 247 static char *ngx_http_log_length(ngx_http_request_t *r, char *buf,
244 uintptr_t data) 248 uintptr_t data)
245 { 249 {
246 return buf + ngx_snprintf(buf, NGX_OFF_T_LEN + 1, OFF_T_FMT, 250 return buf + ngx_snprintf(buf, NGX_OFF_T_LEN + 1, OFF_T_FMT,
247 r->connection->sent); 251 r->connection->sent);
252 }
253
254
255 static char *ngx_http_log_apache_length(ngx_http_request_t *r, char *buf,
256 uintptr_t data)
257 {
258 return buf + ngx_snprintf(buf, NGX_OFF_T_LEN + 1, OFF_T_FMT,
259 r->connection->sent - r->header_size);
248 } 260 }
249 261
250 262
251 static char *ngx_http_log_header_in(ngx_http_request_t *r, char *buf, 263 static char *ngx_http_log_header_in(ngx_http_request_t *r, char *buf,
252 uintptr_t data) 264 uintptr_t data)