Mercurial > hg > nginx
comparison src/http/ngx_http_log_handler.c @ 427:0d08eabe5c7b
nginx-0.0.10-2004-09-15-20:00:43 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 15 Sep 2004 16:00:43 +0000 |
parents | 3c56e834be46 |
children | da8c5707af39 |
comparison
equal
deleted
inserted
replaced
426:3f88935a02e8 | 427:0d08eabe5c7b |
---|---|
135 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 135 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
136 "http log handler"); | 136 "http log handler"); |
137 | 137 |
138 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); |
139 | 139 |
140 if (lcf->off) { | |
141 return NGX_OK; | |
142 } | |
143 | |
140 log = lcf->logs->elts; | 144 log = lcf->logs->elts; |
141 for (l = 0; l < lcf->logs->nelts; l++) { | 145 for (l = 0; l < lcf->logs->nelts; l++) { |
142 | 146 |
143 len = 0; | 147 len = 0; |
144 op = log[l].ops->elts; | 148 op = log[l].ops->elts; |
660 | 664 |
661 static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf) | 665 static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf) |
662 { | 666 { |
663 ngx_http_log_loc_conf_t *conf; | 667 ngx_http_log_loc_conf_t *conf; |
664 | 668 |
665 ngx_test_null(conf, ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t)), | 669 if (!(conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t)))) { |
666 NGX_CONF_ERROR); | 670 return NGX_CONF_ERROR; |
671 } | |
667 | 672 |
668 return conf; | 673 return conf; |
669 } | 674 } |
670 | 675 |
671 | 676 |
678 ngx_http_log_t *log; | 683 ngx_http_log_t *log; |
679 ngx_http_log_fmt_t *fmt; | 684 ngx_http_log_fmt_t *fmt; |
680 ngx_http_log_main_conf_t *lmcf; | 685 ngx_http_log_main_conf_t *lmcf; |
681 | 686 |
682 if (conf->logs == NULL) { | 687 if (conf->logs == NULL) { |
688 | |
689 if (conf->off) { | |
690 return NGX_CONF_OK; | |
691 } | |
692 | |
683 if (prev->logs) { | 693 if (prev->logs) { |
684 conf->logs = prev->logs; | 694 conf->logs = prev->logs; |
685 | 695 |
686 } else { | 696 } else { |
687 | 697 |
688 conf->logs = ngx_create_array(cf->pool, 2, sizeof(ngx_http_log_t)); | 698 if (prev->off) { |
699 conf->off = prev->off; | |
700 return NGX_CONF_OK; | |
701 } | |
702 | |
703 conf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t)); | |
689 if (conf->logs == NULL) { | 704 if (conf->logs == NULL) { |
690 return NGX_CONF_ERROR; | 705 return NGX_CONF_ERROR; |
691 } | 706 } |
692 | 707 |
693 if (!(log = ngx_push_array(conf->logs))) { | 708 if (!(log = ngx_array_push(conf->logs))) { |
694 return NGX_CONF_ERROR; | 709 return NGX_CONF_ERROR; |
695 } | 710 } |
696 | 711 |
697 log->file = ngx_conf_open_file(cf->cycle, &http_access_log); | 712 log->file = ngx_conf_open_file(cf->cycle, &http_access_log); |
698 if (log->file == NULL) { | 713 if (log->file == NULL) { |
699 return NGX_CONF_ERROR; | 714 return NGX_CONF_ERROR; |
700 } | 715 } |
701 | 716 |
702 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); | 717 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); |
703 fmt = lmcf->formats.elts; | 718 fmt = lmcf->formats.elts; |
719 | |
704 /* the default "combined" format */ | 720 /* the default "combined" format */ |
705 log->ops = fmt[0].ops; | 721 log->ops = fmt[0].ops; |
706 } | 722 } |
707 } | 723 } |
708 | 724 |
719 ngx_str_t *value, name; | 735 ngx_str_t *value, name; |
720 ngx_http_log_t *log; | 736 ngx_http_log_t *log; |
721 ngx_http_log_fmt_t *fmt; | 737 ngx_http_log_fmt_t *fmt; |
722 ngx_http_log_main_conf_t *lmcf; | 738 ngx_http_log_main_conf_t *lmcf; |
723 | 739 |
740 value = cf->args->elts; | |
741 | |
742 if (ngx_strcmp(value[1].data, "off") == 0) { | |
743 llcf->off = 1; | |
744 return NGX_CONF_OK; | |
745 } | |
746 | |
724 if (llcf->logs == NULL) { | 747 if (llcf->logs == NULL) { |
725 if (!(llcf->logs = ngx_create_array(cf->pool, 2, | 748 llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t)); |
726 sizeof(ngx_http_log_t)))) { | 749 if (llcf->logs == NULL) { |
727 return NGX_CONF_ERROR; | 750 return NGX_CONF_ERROR; |
728 } | 751 } |
729 } | 752 } |
730 | 753 |
731 value = cf->args->elts; | |
732 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); | 754 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module); |
733 | 755 |
734 if (!(log = ngx_push_array(llcf->logs))) { | 756 if (!(log = ngx_array_push(llcf->logs))) { |
735 return NGX_CONF_ERROR; | 757 return NGX_CONF_ERROR; |
736 } | 758 } |
737 | 759 |
738 if (!(log->file = ngx_conf_open_file(cf->cycle, &value[1]))) { | 760 if (!(log->file = ngx_conf_open_file(cf->cycle, &value[1]))) { |
739 return NGX_CONF_ERROR; | 761 return NGX_CONF_ERROR; |