Mercurial > hg > nginx
comparison src/http/ngx_http_log_handler.c @ 177:4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 10 Nov 2003 17:17:31 +0000 |
parents | c0552e5ab567 |
children | a8ff48d26cca |
comparison
equal
deleted
inserted
replaced
176:c0552e5ab567 | 177:4db54fdbcbe7 |
---|---|
26 static char *ngx_http_log_header_out(ngx_http_request_t *r, char *buf, | 26 static char *ngx_http_log_header_out(ngx_http_request_t *r, char *buf, |
27 uintptr_t data); | 27 uintptr_t data); |
28 static char *ngx_http_log_unknown_header_out(ngx_http_request_t *r, char *buf, | 28 static char *ngx_http_log_unknown_header_out(ngx_http_request_t *r, char *buf, |
29 uintptr_t data); | 29 uintptr_t data); |
30 | 30 |
31 static int ngx_http_log_pre_conf(ngx_conf_t *cf); | |
31 static void *ngx_http_log_create_main_conf(ngx_conf_t *cf); | 32 static void *ngx_http_log_create_main_conf(ngx_conf_t *cf); |
32 static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf); | 33 static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf); |
33 static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, | 34 static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, |
34 void *child); | 35 void *child); |
35 static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, | 36 static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, |
59 ngx_null_command | 60 ngx_null_command |
60 }; | 61 }; |
61 | 62 |
62 | 63 |
63 ngx_http_module_t ngx_http_log_module_ctx = { | 64 ngx_http_module_t ngx_http_log_module_ctx = { |
65 ngx_http_log_pre_conf, /* pre conf */ | |
66 | |
64 ngx_http_log_create_main_conf, /* create main configuration */ | 67 ngx_http_log_create_main_conf, /* create main configuration */ |
65 NULL, /* init main configuration */ | 68 NULL, /* init main configuration */ |
66 | 69 |
67 NULL, /* create server configuration */ | 70 NULL, /* create server configuration */ |
68 NULL, /* merge server configuration */ | 71 NULL, /* merge server configuration */ |
91 static ngx_str_t ngx_http_combined_fmt = | 94 static ngx_str_t ngx_http_combined_fmt = |
92 ngx_string("%addr - - [%time] \"%request\" %status %length " | 95 ngx_string("%addr - - [%time] \"%request\" %status %length " |
93 "\"%{Referer}i\" %{User-Agent}i\""); | 96 "\"%{Referer}i\" %{User-Agent}i\""); |
94 | 97 |
95 | 98 |
96 static ngx_http_log_op_name_t ngx_http_log_fmt_ops[] = { | 99 ngx_http_log_op_name_t ngx_http_log_fmt_ops[] = { |
97 { ngx_string("addr"), INET_ADDRSTRLEN - 1, ngx_http_log_addr }, | 100 { ngx_string("addr"), INET_ADDRSTRLEN - 1, ngx_http_log_addr }, |
98 { ngx_string("conn"), NGX_INT32_LEN, ngx_http_log_connection }, | 101 { ngx_string("conn"), NGX_INT32_LEN, ngx_http_log_connection }, |
99 { ngx_string("pipe"), 1, ngx_http_log_pipe }, | 102 { ngx_string("pipe"), 1, ngx_http_log_pipe }, |
100 { ngx_string("time"), sizeof("28/Sep/1970:12:00:00") - 1, | 103 { ngx_string("time"), sizeof("28/Sep/1970:12:00:00") - 1, |
101 ngx_http_log_time }, | 104 ngx_http_log_time }, |
437 | 440 |
438 return buf + 1; | 441 return buf + 1; |
439 } | 442 } |
440 | 443 |
441 | 444 |
445 static int ngx_http_log_pre_conf(ngx_conf_t *cf) | |
446 { | |
447 ngx_http_log_op_name_t *op; | |
448 | |
449 for (op = ngx_http_log_fmt_ops; op->name.len; op++) { /* void */ } | |
450 op->op = NULL; | |
451 | |
452 return NGX_OK; | |
453 } | |
454 | |
455 | |
442 static void *ngx_http_log_create_main_conf(ngx_conf_t *cf) | 456 static void *ngx_http_log_create_main_conf(ngx_conf_t *cf) |
443 { | 457 { |
444 ngx_http_log_main_conf_t *conf; | 458 ngx_http_log_main_conf_t *conf; |
445 | 459 |
446 char *rc; | 460 char *rc; |
472 | 486 |
473 *value = ngx_http_combined_fmt; | 487 *value = ngx_http_combined_fmt; |
474 | 488 |
475 rc = ngx_http_log_set_format(cf, NULL, conf); | 489 rc = ngx_http_log_set_format(cf, NULL, conf); |
476 if (rc != NGX_CONF_OK) { | 490 if (rc != NGX_CONF_OK) { |
477 return rc; | 491 return NULL; |
478 } | 492 } |
479 | 493 |
480 return conf; | 494 return conf; |
481 } | 495 } |
482 | 496 |
595 ngx_http_log_op_t *op; | 609 ngx_http_log_op_t *op; |
596 ngx_http_log_fmt_t *fmt; | 610 ngx_http_log_fmt_t *fmt; |
597 ngx_http_log_op_name_t *name; | 611 ngx_http_log_op_name_t *name; |
598 | 612 |
599 value = cf->args->elts; | 613 value = cf->args->elts; |
600 #if 0 | |
601 lmcf = ngx_http_conf_module_main_conf(cf, ngx_http_log_module); | |
602 #endif | |
603 | 614 |
604 fmt = lmcf->formats.elts; | 615 fmt = lmcf->formats.elts; |
605 for (f = 0; f < lmcf->formats.nelts; f++) { | 616 for (f = 0; f < lmcf->formats.nelts; f++) { |
606 if (fmt[f].name.len == value[1].len | 617 if (fmt[f].name.len == value[1].len |
607 && ngx_strcmp(fmt->name.data, value[1].data) == 0) | 618 && ngx_strcmp(fmt->name.data, value[1].data) == 0) |
667 } | 678 } |
668 | 679 |
669 fname = &value[s].data[i]; | 680 fname = &value[s].data[i]; |
670 | 681 |
671 while (i < value[s].len | 682 while (i < value[s].len |
672 && value[s].data[i] >= 'a' | 683 && ((value[s].data[i] >= 'a' && value[s].data[i] <= 'z') |
673 && value[s].data[i] <= 'z') | 684 || value[s].data[i] == '_')) |
674 { | 685 { |
675 i++; | 686 i++; |
676 } | 687 } |
677 | 688 |
678 fname_len = &value[s].data[i] - fname; | 689 fname_len = &value[s].data[i] - fname; |
680 if (fname_len == 0) { | 691 if (fname_len == 0) { |
681 invalid = 1; | 692 invalid = 1; |
682 break; | 693 break; |
683 } | 694 } |
684 | 695 |
685 for (name = ngx_http_log_fmt_ops; name->name.len; name++) { | 696 for (name = ngx_http_log_fmt_ops; name->op; name++) { |
697 if (name->name.len == 0) { | |
698 name = (ngx_http_log_op_name_t *) name->op; | |
699 } | |
700 | |
686 if (name->name.len == fname_len | 701 if (name->name.len == fname_len |
687 && ngx_strncmp(name->name.data, fname, fname_len) == 0) | 702 && ngx_strncmp(name->name.data, fname, fname_len) == 0) |
688 { | 703 { |
689 if (name->len != NGX_HTTP_LOG_ARG) { | 704 if (name->len != NGX_HTTP_LOG_ARG) { |
690 if (arg.len) { | 705 if (arg.len) { |