comparison src/http/modules/ngx_http_log_module.c @ 1074:8164f479b362

fix "access_log off"
author Igor Sysoev <igor@sysoev.ru>
date Wed, 24 Jan 2007 09:15:25 +0000
parents bd4202f92581
children 6002e0253221
comparison
equal deleted inserted replaced
1073:d82560e9d147 1074:8164f479b362
153 NULL, /* exit master */ 153 NULL, /* exit master */
154 NGX_MODULE_V1_PADDING 154 NGX_MODULE_V1_PADDING
155 }; 155 };
156 156
157 157
158 static ngx_str_t http_access_log = ngx_string(NGX_HTTP_LOG_PATH); 158 static ngx_str_t ngx_http_access_log = ngx_string(NGX_HTTP_LOG_PATH);
159 159
160 160
161 static ngx_str_t ngx_http_combined_fmt = 161 static ngx_str_t ngx_http_combined_fmt =
162 ngx_string("$remote_addr - $remote_user [$time_local] " 162 ngx_string("$remote_addr - $remote_user [$time_local] "
163 "\"$request\" $status $body_bytes_sent " 163 "\"$request\" $status $body_bytes_sent "
552 552
553 ngx_http_log_t *log; 553 ngx_http_log_t *log;
554 ngx_http_log_fmt_t *fmt; 554 ngx_http_log_fmt_t *fmt;
555 ngx_http_log_main_conf_t *lmcf; 555 ngx_http_log_main_conf_t *lmcf;
556 556
557 if (conf->logs || conf->off) {
558 return NGX_CONF_OK;
559 }
560
561 *conf = *prev;
562
563 if (conf->logs || conf->off) {
564 return NGX_CONF_OK;
565 }
566
567 conf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
557 if (conf->logs == NULL) { 568 if (conf->logs == NULL) {
558 569 return NGX_CONF_ERROR;
559 if (conf->off) { 570 }
560 return NGX_CONF_OK; 571
561 } 572 log = ngx_array_push(conf->logs);
562 573 if (log == NULL) {
563 if (prev->logs) { 574 return NGX_CONF_ERROR;
564 conf->logs = prev->logs; 575 }
565 576
566 } else { 577 log->file = ngx_conf_open_file(cf->cycle, &ngx_http_access_log);
567 578 if (log->file == NULL) {
568 if (prev->off) { 579 return NGX_CONF_ERROR;
569 conf->off = prev->off; 580 }
570 return NGX_CONF_OK; 581
571 } 582 log->disk_full_time = 0;
572 583 log->error_log_time = 0;
573 conf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t)); 584
574 if (conf->logs == NULL) { 585 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
575 return NGX_CONF_ERROR; 586 fmt = lmcf->formats.elts;
576 } 587
577 588 /* the default "combined" format */
578 log = ngx_array_push(conf->logs); 589 log->ops = fmt[0].ops;
579 if (log == NULL) { 590 lmcf->combined_used = 1;
580 return NGX_CONF_ERROR;
581 }
582
583 log->file = ngx_conf_open_file(cf->cycle, &http_access_log);
584 if (log->file == NULL) {
585 return NGX_CONF_ERROR;
586 }
587
588 log->disk_full_time = 0;
589 log->error_log_time = 0;
590
591 lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
592 fmt = lmcf->formats.elts;
593
594 /* the default "combined" format */
595 log->ops = fmt[0].ops;
596 lmcf->combined_used = 1;
597 }
598 }
599 591
600 return NGX_CONF_OK; 592 return NGX_CONF_OK;
601 } 593 }
602 594
603 595