Mercurial > hg > nginx
comparison src/core/ngx_log.c @ 4012:bf452af6c1d2
Complain on invalid log levels.
Previously only first log level was required to be correct, while error_log
directive in fact accepts list of levels (e.g. one may specify "error_log ...
debug_core debug_http;"). This resulted in (avoidable) wierd behaviour on
missing semicolon after error_log directive, e.g.
error_log /path/to/log info
index index.php;
silently skipped index directive and it's arguments (trying to interpret
them as log levels without checking to be correct).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 18 Aug 2011 21:48:13 +0000 |
parents | 8ccd6ed1d4bb |
children | d620f497c50f |
comparison
equal
deleted
inserted
replaced
4011:9d4cbb09ae8b | 4012:bf452af6c1d2 |
---|---|
367 | 367 |
368 | 368 |
369 char * | 369 char * |
370 ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log) | 370 ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log) |
371 { | 371 { |
372 ngx_uint_t i, n, d; | 372 ngx_uint_t i, n, d, found; |
373 ngx_str_t *value; | 373 ngx_str_t *value; |
374 | 374 |
375 value = cf->args->elts; | 375 value = cf->args->elts; |
376 | 376 |
377 for (i = 2; i < cf->args->nelts; i++) { | 377 for (i = 2; i < cf->args->nelts; i++) { |
378 found = 0; | |
378 | 379 |
379 for (n = 1; n <= NGX_LOG_DEBUG; n++) { | 380 for (n = 1; n <= NGX_LOG_DEBUG; n++) { |
380 if (ngx_strcmp(value[i].data, err_levels[n].data) == 0) { | 381 if (ngx_strcmp(value[i].data, err_levels[n].data) == 0) { |
381 | 382 |
382 if (log->log_level != 0) { | 383 if (log->log_level != 0) { |
385 &value[i]); | 386 &value[i]); |
386 return NGX_CONF_ERROR; | 387 return NGX_CONF_ERROR; |
387 } | 388 } |
388 | 389 |
389 log->log_level = n; | 390 log->log_level = n; |
390 continue; | 391 found = 1; |
392 break; | |
391 } | 393 } |
392 } | 394 } |
393 | 395 |
394 for (n = 0, d = NGX_LOG_DEBUG_FIRST; d <= NGX_LOG_DEBUG_LAST; d <<= 1) { | 396 for (n = 0, d = NGX_LOG_DEBUG_FIRST; d <= NGX_LOG_DEBUG_LAST; d <<= 1) { |
395 if (ngx_strcmp(value[i].data, debug_levels[n++]) == 0) { | 397 if (ngx_strcmp(value[i].data, debug_levels[n++]) == 0) { |
399 &value[i]); | 401 &value[i]); |
400 return NGX_CONF_ERROR; | 402 return NGX_CONF_ERROR; |
401 } | 403 } |
402 | 404 |
403 log->log_level |= d; | 405 log->log_level |= d; |
406 found = 1; | |
407 break; | |
404 } | 408 } |
405 } | 409 } |
406 | 410 |
407 | 411 |
408 if (log->log_level == 0) { | 412 if (!found) { |
409 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 413 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
410 "invalid log level \"%V\"", &value[i]); | 414 "invalid log level \"%V\"", &value[i]); |
411 return NGX_CONF_ERROR; | 415 return NGX_CONF_ERROR; |
412 } | 416 } |
413 } | 417 } |