Mercurial > hg > nginx-quic
diff src/core/ngx_log.c @ 92:19cc647ecd91
nginx-0.0.1-2003-05-20-19:37:55 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 20 May 2003 15:37:55 +0000 |
parents | a7e45c45a95c |
children | 738fe44c70d5 |
line wrap: on
line diff
--- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -11,15 +11,12 @@ */ #include <ngx_config.h> -#include <ngx_errno.h> -#include <ngx_time.h> -#include <ngx_process.h> -#include <ngx_string.h> -#include <ngx_log.h> +#include <ngx_core.h> static const char *err_levels[] = { - "emerg", "alert", "crit", "error", "warn", "notice", "info", "debug" + "stderr", "emerg", "alert", "crit", "error", + "warn", "notice", "info", "debug" }; #if (HAVE_VARIADIC_MACROS) @@ -30,11 +27,11 @@ void ngx_log_error_core(int level, ngx_l const char *fmt, va_list args) #endif { - char errstr[MAX_ERROR_STR]; - ngx_tm_t tm; - size_t len; + char errstr[MAX_ERROR_STR]; + ngx_tm_t tm; + size_t len; #if (HAVE_VARIADIC_MACROS) - va_list args; + va_list args; #endif ngx_localtime(&tm); @@ -93,7 +90,7 @@ void ngx_log_error_core(int level, ngx_l #endif errstr[len++] = '\n'; - write(2, errstr, len); + write(log->fd, errstr, len); #if 0 errstr[len] = '\0'; @@ -102,6 +99,7 @@ void ngx_log_error_core(int level, ngx_l #endif } + #if !(HAVE_VARIADIC_MACROS) void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err, @@ -116,6 +114,7 @@ void ngx_log_error(int level, ngx_log_t } } + void ngx_log_debug_core(ngx_log_t *log, const char *fmt, ...) { va_list args; @@ -125,6 +124,7 @@ void ngx_log_debug_core(ngx_log_t *log, va_end(args); } + void ngx_assert_core(ngx_log_t *log, const char *fmt, ...) { va_list args; @@ -135,3 +135,33 @@ void ngx_assert_core(ngx_log_t *log, con } #endif + + +void ngx_log_stderr(ngx_event_t *ev) +{ + char errstr[MAX_ERROR_STR]; + ssize_t n; + ngx_err_t err; + + for ( ;; ) { + n = read((ngx_fd_t) ev->data, errstr, sizeof(errstr - 1)); + + if (n == -1) { + err = ngx_errno; + if (err == NGX_EAGAIN) { + return; + } + + ngx_log_error(NGX_LOG_ALERT, &ngx_log, err, "read() failed"); + return; + } + + if (n == 0) { + ngx_log_error(NGX_LOG_ALERT, &ngx_log, 0, "stderr clolsed"); + return; + } + + errstr[n] = '\0'; + ngx_log_error(NGX_LOG_STDERR, &ngx_log, 0, "%s", errstr); + } +}