diff src/core/ngx_log.c @ 2722:ffa8e2451457

show -t results on stderr
author Igor Sysoev <igor@sysoev.ru>
date Sun, 19 Apr 2009 16:06:09 +0000
parents dbd02ee65df4
children d43d73277c5c
line wrap: on
line diff
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -190,6 +190,27 @@ ngx_log_abort(ngx_err_t err, const char 
 }
 
 
+void ngx_cdecl
+ngx_log_stderr(const char *fmt, ...)
+{
+    u_char   *p;
+    va_list   args;
+    u_char    errstr[NGX_MAX_ERROR_STR];
+
+    va_start(args, fmt);
+    p = ngx_vsnprintf(errstr, NGX_MAX_ERROR_STR, fmt, args);
+    va_end(args);
+
+    if (p > errstr + NGX_MAX_ERROR_STR - NGX_LINEFEED_SIZE) {
+        p = errstr + NGX_MAX_ERROR_STR - NGX_LINEFEED_SIZE;
+    }
+
+    ngx_linefeed(p);
+
+    (void) ngx_write_fd(ngx_stderr_fileno, errstr, p - errstr);
+}
+
+
 ngx_log_t *
 ngx_log_init(void)
 {