Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_log_handler.c @ 26:53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 15 Dec 2002 06:25:09 +0000 |
parents | |
children | a117a7fdf042 |
comparison
equal
deleted
inserted
replaced
25:a8b156554dfe | 26:53cb81681040 |
---|---|
1 | |
2 #include <ngx_config.h> | |
3 #include <ngx_core.h> | |
4 #include <ngx_string.h> | |
5 #include <ngx_alloc.h> | |
6 #include <ngx_time.h> | |
7 #include <ngx_http.h> | |
8 | |
9 | |
10 ngx_http_module_t ngx_http_log_module; | |
11 | |
12 | |
13 static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", | |
14 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; | |
15 | |
16 | |
17 int ngx_http_log_handler(ngx_http_request_t *r) | |
18 { | |
19 size_t len; | |
20 char *line, *p; | |
21 ngx_tm_t tm; | |
22 | |
23 #if (WIN32) | |
24 len = 2 + 22 + 3 + 20 + 5 + 20 + 2; | |
25 #else | |
26 len = 2 + 22 + 3 + 20 + 5 + 20 + 1; | |
27 #endif | |
28 | |
29 len += r->connection->addr_text.len; | |
30 len += r->request_line.len; | |
31 | |
32 | |
33 ngx_test_null(line, ngx_palloc(r->pool, len), NGX_ERROR); | |
34 p = line; | |
35 | |
36 ngx_memcpy(p, r->connection->addr_text.data, r->connection->addr_text.len); | |
37 p += r->connection->addr_text.len; | |
38 | |
39 *p++ = ' '; | |
40 | |
41 ngx_localtime(&tm); | |
42 | |
43 *p++ = '['; | |
44 p += ngx_snprintf(p, 21, "%02d/%s/%d:%02d:%02d:%02d", | |
45 tm.ngx_tm_mday, months[tm.ngx_tm_mon], | |
46 tm.ngx_tm_year + 1900, | |
47 tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec); | |
48 | |
49 *p++ = ']'; | |
50 | |
51 *p++ = ' '; | |
52 | |
53 *p++ = '"'; | |
54 ngx_memcpy(p, r->request_line.data, r->request_line.len); | |
55 p += r->request_line.len; | |
56 *p++ = '"'; | |
57 | |
58 *p++ = ' '; | |
59 | |
60 p += ngx_snprintf(p, 4, "%d", r->headers_out.status); | |
61 | |
62 *p++ = ' '; | |
63 | |
64 p += ngx_snprintf(p, 21, QD_FMT, r->connection->sent); | |
65 | |
66 *p++ = ' '; | |
67 | |
68 p += ngx_snprintf(p, 21, "%u", r->connection->number); | |
69 | |
70 #if (WIN32) | |
71 *p++ = CR; *p++ = LF; | |
72 #else | |
73 *p++ = LF; | |
74 #endif | |
75 | |
76 write(1, line, len); | |
77 | |
78 return NGX_OK; | |
79 } |