Mercurial > hg > nginx
comparison src/http/modules/ngx_http_log_handler.c @ 28:a117a7fdf042
nginx-0.0.1-2002-12-16-00:08:04 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 15 Dec 2002 21:08:04 +0000 |
parents | 53cb81681040 |
children | d45effe5854c |
comparison
equal
deleted
inserted
replaced
27:a8d5abe713e6 | 28:a117a7fdf042 |
---|---|
18 { | 18 { |
19 size_t len; | 19 size_t len; |
20 char *line, *p; | 20 char *line, *p; |
21 ngx_tm_t tm; | 21 ngx_tm_t tm; |
22 | 22 |
23 ngx_log_debug(r->connection->log, "log handler"); | |
24 | |
25 /* %a, 20:%c, 22:%d, 3:%s, 20:%b, 5*" ", "2/1: "\r\n" */ | |
23 #if (WIN32) | 26 #if (WIN32) |
24 len = 2 + 22 + 3 + 20 + 5 + 20 + 2; | 27 len = 2 + 20 + 22 + 3 + 20 + 5 + + 2; |
25 #else | 28 #else |
26 len = 2 + 22 + 3 + 20 + 5 + 20 + 1; | 29 len = 2 + 20 + 22 + 3 + 20 + 5 + + 1; |
27 #endif | 30 #endif |
28 | 31 |
29 len += r->connection->addr_text.len; | 32 len += r->connection->addr_text.len; |
30 len += r->request_line.len; | 33 len += r->request_line.len; |
31 | 34 |
35 ngx_log_debug(r->connection->log, "log handler: %d" _ len); | |
32 | 36 |
33 ngx_test_null(line, ngx_palloc(r->pool, len), NGX_ERROR); | 37 ngx_test_null(line, ngx_palloc(r->pool, len), NGX_ERROR); |
34 p = line; | 38 p = line; |
35 | 39 |
36 ngx_memcpy(p, r->connection->addr_text.data, r->connection->addr_text.len); | 40 ngx_memcpy(p, r->connection->addr_text.data, r->connection->addr_text.len); |
37 p += r->connection->addr_text.len; | 41 p += r->connection->addr_text.len; |
38 | 42 |
39 *p++ = ' '; | 43 *p++ = ' '; |
40 | 44 |
45 p += ngx_snprintf(p, 21, "%u", r->connection->number); | |
46 | |
47 *p++ = ' '; | |
48 | |
49 *p = '\0'; | |
50 ngx_log_debug(r->connection->log, "log handler: %s" _ line); | |
51 | |
41 ngx_localtime(&tm); | 52 ngx_localtime(&tm); |
53 | |
54 ngx_log_debug(r->connection->log, "log handler: %s" _ line); | |
42 | 55 |
43 *p++ = '['; | 56 *p++ = '['; |
44 p += ngx_snprintf(p, 21, "%02d/%s/%d:%02d:%02d:%02d", | 57 p += ngx_snprintf(p, 21, "%02d/%s/%d:%02d:%02d:%02d", |
45 tm.ngx_tm_mday, months[tm.ngx_tm_mon], | 58 tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1], |
46 tm.ngx_tm_year + 1900, | 59 tm.ngx_tm_year, |
47 tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec); | 60 tm.ngx_tm_hour, tm.ngx_tm_min, tm.ngx_tm_sec); |
48 | 61 |
49 *p++ = ']'; | 62 *p++ = ']'; |
50 | 63 |
51 *p++ = ' '; | 64 *p++ = ' '; |
65 | |
66 *p = '\0'; | |
67 ngx_log_debug(r->connection->log, "log handler: %s" _ line); | |
52 | 68 |
53 *p++ = '"'; | 69 *p++ = '"'; |
54 ngx_memcpy(p, r->request_line.data, r->request_line.len); | 70 ngx_memcpy(p, r->request_line.data, r->request_line.len); |
55 p += r->request_line.len; | 71 p += r->request_line.len; |
56 *p++ = '"'; | 72 *p++ = '"'; |
61 | 77 |
62 *p++ = ' '; | 78 *p++ = ' '; |
63 | 79 |
64 p += ngx_snprintf(p, 21, QD_FMT, r->connection->sent); | 80 p += ngx_snprintf(p, 21, QD_FMT, r->connection->sent); |
65 | 81 |
66 *p++ = ' '; | 82 *p = '\0'; |
67 | 83 ngx_log_debug(r->connection->log, "log handler: %s" _ line); |
68 p += ngx_snprintf(p, 21, "%u", r->connection->number); | |
69 | 84 |
70 #if (WIN32) | 85 #if (WIN32) |
71 *p++ = CR; *p++ = LF; | 86 *p++ = CR; *p++ = LF; |
72 #else | 87 #else |
73 *p++ = LF; | 88 *p++ = LF; |
74 #endif | 89 #endif |
75 | 90 |
91 *p = '\0'; | |
92 ngx_log_debug(r->connection->log, "log handler: %s" _ line); | |
93 | |
76 write(1, line, len); | 94 write(1, line, len); |
77 | 95 |
78 return NGX_OK; | 96 return NGX_OK; |
79 } | 97 } |