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; va_list args; last = errstr + NGX_MAX_CONF_ERRSTR; va_start(args, fmt); buf = 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 (cf->conf_file == NULL) { ngx_log_error(level, cf->log, 0, "%s", errstr); return; } ngx_log_error(level, cf->log, 0, "%s in %s:%ui", errstr, cf->conf_file->file.name.data, cf->conf_file->line); }
void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...) { u_char *p; va_list args; u_char errstr[NGX_MAX_CONF_ERRSTR]; va_start(args, fmt); p = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args); va_end(args); ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, err, "%*s", p - errstr, errstr); }
ngx_int_t ngx_http_google_debug(ngx_pool_t * pool, const char * fmt, ...) { u_char * buf; ngx_uint_t len = 4096; buf = ngx_pcalloc(pool, len + 1); if (!buf) { return fprintf(stderr, "ngx_pcalloc(%lu) failed\n", (unsigned long)len); } va_list args; va_start(args, fmt); ngx_vsnprintf(buf, len, fmt, args); va_end(args); return fprintf(stdout, "%s", buf); }
void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err, char *fmt, ...) { int len; char errstr[NGX_MAX_CONF_ERRSTR]; va_list args; va_start(args, fmt); len = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args); va_end(args); if (err) { len += ngx_snprintf(errstr + len, sizeof(errstr) - len - 1, " (%d: ", err); len += ngx_strerror_r(err, errstr + len, sizeof(errstr) - len - 1); errstr[len++] = ')'; errstr[len] = '\0'; } ngx_log_error(level, cf->log, 0, "%s in %s:%d", errstr, cf->conf_file->file.name.data, cf->conf_file->line); }
void ngx_ssl_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, char *fmt, ...) { int len; char errstr[NGX_MAX_CONF_ERRSTR]; va_list args; va_start(args, fmt); len = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args); va_end(args); errstr[len++] = ' '; errstr[len++] = '('; errstr[len++] = 'S'; errstr[len++] = 'S'; errstr[len++] = 'L'; errstr[len++] = ':'; errstr[len++] = ' '; ERR_error_string_n(ERR_get_error(), errstr + len, sizeof(errstr) - len - 1); ngx_log_error(level, log, err, "%s)", errstr); }
void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, const char *fmt, va_list args) #endif { #if (NGX_HAVE_VARIADIC_MACROS) va_list args; #endif u_char errstr[NGX_MAX_ERROR_STR], *p, *last; if (log->file->fd == NGX_INVALID_FILE) { return; } last = errstr + NGX_MAX_ERROR_STR; ngx_memcpy(errstr, ngx_cached_err_log_time.data, ngx_cached_err_log_time.len); p = errstr + ngx_cached_err_log_time.len; p = ngx_snprintf(p, last - p, " [%s] ", err_levels[level]); /* pid#tid */ p = ngx_snprintf(p, last - p, "%P#" NGX_TID_T_FMT ": ", ngx_log_pid, ngx_log_tid); if (log->connection) { p = ngx_snprintf(p, last - p, "*%uA ", log->connection); } #if (NGX_HAVE_VARIADIC_MACROS) va_start(args, fmt); p = ngx_vsnprintf(p, last - p, fmt, args); va_end(args); #else p = ngx_vsnprintf(p, last - p, fmt, args); #endif if (err) { if (p > last - 50) { /* leave a space for an error code */ p = last - 50; *p++ = '.'; *p++ = '.'; *p++ = '.'; } #if (NGX_WIN32) if ((unsigned) err >= 0x80000000) { p = ngx_snprintf(p, last - p, " (%Xd: ", err); } else { p = ngx_snprintf(p, last - p, " (%d: ", err); } #else p = ngx_snprintf(p, last - p, " (%d: ", err); #endif p = ngx_strerror_r(err, p, last - p); if (p < last) { *p++ = ')'; } } if (level != NGX_LOG_DEBUG && log->handler) { p = log->handler(log, p, last - p); } if (p > last - NGX_LINEFEED_SIZE) { p = last - NGX_LINEFEED_SIZE; } ngx_linefeed(p); (void) ngx_write_fd(log->file->fd, errstr, p - errstr); }