aboutsummaryrefslogtreecommitdiff
path: root/src/core/ngx_log.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-05-20 15:37:55 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-05-20 15:37:55 +0000
commit1c13c662f0ae8066d1d4849b4158d7459a4c7822 (patch)
treea8e517c0d41e922b1d3744d869edc60ed540b2d9 /src/core/ngx_log.c
parenta98301160de4c12f455cca8f78509f2e04626c0b (diff)
downloadnginx-1c13c662f0ae8066d1d4849b4158d7459a4c7822.tar.gz
nginx-1c13c662f0ae8066d1d4849b4158d7459a4c7822.zip
nginx-0.0.1-2003-05-20-19:37:55 import
Diffstat (limited to 'src/core/ngx_log.c')
-rw-r--r--src/core/ngx_log.c52
1 files changed, 41 insertions, 11 deletions
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 4057d7a81..fee60187c 100644
--- 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_log_t *log, ngx_err_t err,
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_log_t *log, ngx_err_t err,
#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_log_t *log, ngx_err_t err,
#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 *log, ngx_err_t err,
}
}
+
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, const char *fmt, ...)
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, const char *fmt, ...)
}
#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);
+ }
+}