diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-11-25 16:00:53 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-11-25 16:00:53 +0300 |
commit | ecbb69ad7f775a71d82d5b1c79493e33913a4620 (patch) | |
tree | ecb44add92b25f2d705dd1e9de8783228e9c995b /src/core/ngx_conf_file.c | |
parent | 33930d82ce80dd4cd2c20e732940d4c88e411a98 (diff) |
*) increase ngx_conf_log_error() buffer
*) always log an error code
Diffstat (limited to 'src/core/ngx_conf_file.c')
-rw-r--r-- | src/core/ngx_conf_file.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index 31d00de39..d06c4da8e 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -959,31 +959,47 @@ void ngx_cdecl ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err, char *fmt, ...) { - u_char errstr[NGX_MAX_CONF_ERRSTR], *buf, *last; + u_char errstr[NGX_MAX_CONF_ERRSTR], *p, *last; va_list args; last = errstr + NGX_MAX_CONF_ERRSTR; va_start(args, fmt); - buf = ngx_vsnprintf(errstr, last - errstr, fmt, args); + p = ngx_vsnprintf(errstr, last - errstr, fmt, args); va_end(args); - *buf = '\0'; - if (err) { - buf = ngx_snprintf(buf, last - buf - 1, " (%d: ", err); - buf = ngx_strerror_r(err, buf, last - buf - 1); - *buf++ = ')'; - *buf = '\0'; + + if (p > last - 50) { + + /* leave a space for an error code */ + + p = last - 50; + *p++ = '.'; + *p++ = '.'; + *p++ = '.'; + } + +#if (NGX_WIN32) + p = ngx_snprintf(p, last - p, ((unsigned) err < 0x80000000) + ? " (%d: " : " (%Xd: ", err); +#else + p = ngx_snprintf(p, last - p, " (%d: ", err); +#endif + + p = ngx_strerror_r(err, p, last - p); + + *p++ = ')'; } if (cf->conf_file == NULL) { - ngx_log_error(level, cf->log, 0, "%s", errstr); + ngx_log_error(level, cf->log, 0, "%*s", p - errstr, errstr); return; } - ngx_log_error(level, cf->log, 0, "%s in %s:%ui", - errstr, cf->conf_file->file.name.data, cf->conf_file->line); + ngx_log_error(level, cf->log, 0, "%*s in %s:%ui", + p - errstr, errstr, + cf->conf_file->file.name.data, cf->conf_file->line); } |