nginx-0.0.2-2004-02-11-20:08:49 import
diff --git a/src/core/ngx_alloc.c b/src/core/ngx_alloc.c
index dff0593..ae96564 100644
--- a/src/core/ngx_alloc.c
+++ b/src/core/ngx_alloc.c
@@ -12,9 +12,7 @@
                       "malloc() %d bytes failed", size);
     }
 
-#if (NGX_DEBUG_ALLOC)
-    ngx_log_debug(log, "malloc: %08x:%d" _ p _ size);
-#endif
+    ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0, "malloc: %08x:%d", p, size);
 
     return p;
 }
@@ -57,27 +55,30 @@
     ngx_pool_large_t  *l;
 
     for (l = pool->large; l; l = l->next) {
-#if (NGX_DEBUG_ALLOC)
-        ngx_log_debug(pool->log, "free: %08x" _ l->alloc);
-#endif
+
+        ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
+                       "free: %08x", l->alloc);
+
         if (l->alloc) {
             free(l->alloc);
         }
     }
 
+#if (NGX_DEBUG)
+
     /*
-     * we could allocate pool->log from this pool
-     * so we can not use this log while free()ing the pool
+     * we could allocate the pool->log from this pool
+     * so we can not use this log while the free()ing the pool
      */
 
-#if (NGX_DEBUG_ALLOC)
     for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
-        ngx_log_debug(pool->log, "free: %08x" _ p);
+        ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, "free: %08x", p);
 
         if (n == NULL) {
             break;
         }
     }
+
 #endif
 
     for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
@@ -177,9 +178,8 @@
 
     for (l = pool->large; l; l = l->next) {
         if (p == l->alloc) {
-#if (NGX_DEBUG_ALLOC)
-            ngx_log_debug(pool->log, "free: %08x" _ l->alloc);
-#endif
+            ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
+                           "free: %08x", l->alloc);
             free(l->alloc);
             l->alloc = NULL;
         }
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 704365c..f8e7f7b 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -540,7 +540,7 @@
 }
 
 
-void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err,
+void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err,
                         char *fmt, ...)
 {
     int      len;
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index e1c4e33..6e81f2b 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -238,7 +238,7 @@
 
 
 ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name);
-void ngx_conf_log_error(int level, ngx_conf_t *cf, ngx_err_t err,
+void ngx_conf_log_error(ngx_uint_t level, ngx_conf_t *cf, ngx_err_t err,
                         char *fmt, ...);
 
 
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 1157484..989a0de 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -240,7 +240,7 @@
 
 ngx_int_t ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text)
 {
-    ngx_int_t  level;
+    ngx_uint_t  level;
 
     if (err == NGX_ECONNRESET
         && c->log_error == NGX_ERROR_IGNORE_ECONNRESET)
@@ -252,6 +252,7 @@
 
         switch (c->log_error) {
 
+        case NGX_ERROR_IGNORE_ECONNRESET:
         case NGX_ERROR_INFO:
             level = NGX_LOG_INFO;
             break;
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index f80271d..017db87 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -464,7 +464,7 @@
     log = ngx_cycle->log;
     ngx_temp_pool->log = log;
 
-    ngx_log_debug(log, "clean old cycles");
+    ngx_log_debug0(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycles");
 
     live = 0;
 
@@ -480,7 +480,9 @@
         for (n = 0; n < cycle[i]->connection_n; n++) {
             if (cycle[i]->connections[n].fd != -1) {
                 found = 1;
-                ngx_log_debug(log, "live fd: %d" _ n);
+
+                ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "live fd:%d", n);
+
                 break;
             }
         }
@@ -490,15 +492,15 @@
             continue;
         }
 
-        ngx_log_debug(log, "clean old cycle: %d" _ i);
+        ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycle: %d", i);
+
         ngx_destroy_pool(cycle[i]->pool);
         cycle[i] = NULL;
     }
 
-    ngx_log_debug(log, "old cycles status: %d" _ live);
+    ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "old cycles status: %d", live);
 
     if (live) {
-        ngx_log_debug(log, "TIMER");
         ngx_add_timer(ev, 30000);
 
     } else {
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 3b29bec..72d7ba7 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -75,7 +75,8 @@
 #endif
         file->fd = ngx_open_tempfile(file->name.data, 1);
 
-ngx_log_debug(file->log, "temp fd: %d" _ file->fd);
+        ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
+                       "temp fd:%d", file->fd);
 
         if (file->fd != NGX_INVALID_FILE) {
             return NGX_OK;
@@ -123,15 +124,14 @@
             break;
         }
 
-        ngx_log_debug(file->log, "hashed path: %s" _ file->name.data);
-
         name -= level;
         file->name.data[pos - 1] = '/';
         ngx_memcpy(&file->name.data[pos], &file->name.data[name], level);
         pos += level + 1;
     }
 
-    ngx_log_debug(file->log, "hashed path: %s" _ file->name.data);
+    ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
+                   "hashed path: %s", file->name.data);
 }
 
 
@@ -151,7 +151,8 @@
 
         file->name.data[pos] = '\0';
 
-        ngx_log_debug(file->log, "temp: %s" _ file->name.data);
+        ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
+                       "temp file: \"%s\"", file->name.data);
 
         if (ngx_create_dir(file->name.data) == NGX_FILE_ERROR) {
             err = ngx_errno;
diff --git a/src/core/ngx_garbage_collector.c b/src/core/ngx_garbage_collector.c
index f60fae9..35a060b 100644
--- a/src/core/ngx_garbage_collector.c
+++ b/src/core/ngx_garbage_collector.c
@@ -79,7 +79,8 @@
 
     buf.len = 0;
 
-ngx_log_debug(ctx->log, "dir '%s':%d" _ dname->data _ dname->len);
+    ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0,
+                   "gc dir \"%s\":%d", dname->data, dname->len);
 
     if (ngx_open_dir(dname, &dir) == NGX_ERROR) {
         ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno,
@@ -106,7 +107,8 @@
 
         len = ngx_de_namelen(&dir);
 
-ngx_log_debug(ctx->log, "name '%s':%d" _ ngx_de_name(&dir) _ len);
+        ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0,
+                      "gc name \"%s\":%d", ngx_de_name(&dir), len);
 
         if (len == 1 && ngx_de_name(&dir)[0] == '.') {
             continue;
@@ -139,7 +141,8 @@
         ngx_memcpy(last, ngx_de_name(&dir), len + 1);
         fname.data = buf.data;
 
-ngx_log_debug(ctx->log, "path %s" _ fname.data);
+        ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
+                       "gc path: \"%s\"", fname.data);
 
         if (!dir.info_valid) {
             if (ngx_de_info(fname.data, &dir) == NGX_FILE_ERROR) {
@@ -151,7 +154,8 @@
 
         if (ngx_de_is_dir(&dir)) {
 
-ngx_log_debug(ctx->log, "enter %s" _ fname.data);
+            ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
+                           "gc enter dir \"%s\"", fname.data);
 
             if (level == -1
                    /* there can not be directory on the last level */
@@ -187,7 +191,8 @@
 
         } else if (ngx_de_is_file(&dir)) {
 
-ngx_log_debug(ctx->log, "file %s" _ fname.data);
+            ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
+                           "gc file \"%s\"", fname.data);
 
             if (level == -1
                 || (level < NGX_MAX_PATH_LEVEL && ctx->path->level[level] != 0))
@@ -239,10 +244,10 @@
                                        ngx_dir_t *dir)
 {
     /*
-     * we use mtime only and do not use atime because:
+     * We use mtime only and do not use atime because:
      *    on NTFS access time has a resolution of 1 hour,
      *    on NT FAT access time has a resolution of 1 day,
-     *    Unices have mount option "noatime"
+     *    Unices have the mount option "noatime".
      */
 
     if (ngx_cached_time - ngx_de_mtime(dir) < 3600) {
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index a902f1e..7fdd898 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -42,7 +42,7 @@
 };
 
 static const char *debug_levels[] = {
-    "debug", "debug_core", "debug_alloc", "debug_event", "debug_http"
+    "debug_core", "debug_alloc", "debug_event", "debug_http"
 };
 
 
@@ -81,9 +81,9 @@
     len += ngx_snprintf(errstr + len, max - len,
                         PID_T_FMT "#%d: ", ngx_pid, /* STUB */ 0);
 
-    if (log->data) {
+    if (log->data && *(int *) log->data != -1) {
         len += ngx_snprintf(errstr + len, max - len,
-                            "*%u ", * (u_int *) log->data);
+                            "*%u ", *(u_int *) log->data);
     }
 
 #if (HAVE_VARIADIC_MACROS)
@@ -332,7 +332,7 @@
 
     for (i = 2; i < cf->args->nelts; i++) {
 
-        for (n = 1; n < NGX_LOG_DEBUG; n++) {
+        for (n = 1; n <= NGX_LOG_DEBUG; n++) {
             if (ngx_strcmp(value[i].data, err_levels[n]) == 0) {
 
                 if (log->log_level != 0) {
@@ -368,5 +368,9 @@
         }
     }
 
+    if (log->log_level == NGX_LOG_DEBUG) {
+        log->log_level = NGX_LOG_DEBUG_ALL;
+    }
+
     return NGX_CONF_OK;
 }
diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h
index 15498e1..46fbf12 100644
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -21,9 +21,9 @@
 #define NGX_LOG_DEBUG_EVENT     0x40
 #define NGX_LOG_DEBUG_HTTP      0x80
 
-#define NGX_LOG_DEBUG_FIRST     NGX_LOG_DEBUG
+#define NGX_LOG_DEBUG_FIRST     NGX_LOG_DEBUG_CORE
 #define NGX_LOG_DEBUG_LAST      NGX_LOG_DEBUG_HTTP
-#define NGX_LOG_DEBUG_ALL       0xfffffff8
+#define NGX_LOG_DEBUG_ALL       0xfffffff0
 
 
 /*
@@ -74,7 +74,7 @@
 
 
 struct ngx_log_s {
-    int                  log_level;
+    ngx_uint_t           log_level;
     ngx_open_file_t     *file;
     void                *data;
     ngx_log_handler_pt   handler;
@@ -82,8 +82,6 @@
 
 #define MAX_ERROR_STR	2048
 
-#define _               ,
-
 
 /*********************************/
 
@@ -94,21 +92,6 @@
 #define ngx_log_error(level, log, args...) \
         if (log->log_level >= level) ngx_log_error_core(level, log, args)
 
-#if (NGX_DEBUG)
-#define ngx_log_debug(log, args...) \
-    if (log->log_level & NGX_LOG_DEBUG) \
-        ngx_log_error_core(NGX_LOG_DEBUG, log, 0, args)
-#else
-#define ngx_log_debug(log, args...)
-#endif
-
-#define ngx_assert(assert, fallback, log, args...) \
-        if (!(assert)) { \
-            if (log->log_level >= NGX_LOG_ALERT) \
-                ngx_log_error_core(NGX_LOG_ALERT, log, 0, args); \
-            fallback; \
-        }
-
 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
                         const char *fmt, ...);
 
@@ -121,21 +104,6 @@
 #define ngx_log_error(level, log, ...) \
         if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)
 
-#if (NGX_DEBUG)
-#define ngx_log_debug(log, ...) \
-    if (log->log_level == NGX_LOG_DEBUG) \
-        ngx_log_error_core(NGX_LOG_DEBUG, log, 0, __VA_ARGS__)
-#else
-#define ngx_log_debug(log, ...)
-#endif
-
-#define ngx_assert(assert, fallback, log, ...) \
-        if (!(assert)) { \
-            if (log->log_level >= NGX_LOG_ALERT) \
-                ngx_log_error_core(NGX_LOG_ALERT, log, 0, __VA_ARGS__); \
-            fallback; \
-        }
-
 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
                         const char *fmt, ...);
 
@@ -145,21 +113,6 @@
 
 #define HAVE_VARIADIC_MACROS  0
 
-#if (NGX_DEBUG)
-#define ngx_log_debug(log, text) \
-    if (log->log_level == NGX_LOG_DEBUG) \
-        ngx_log_debug_core(log, 0, text)
-#else
-#define ngx_log_debug(log, text)
-#endif
-
-#define ngx_assert(assert, fallback, log, text) \
-        if (!(assert)) { \
-            if (log->log_level >= NGX_LOG_ALERT) \
-                ngx_assert_core(log, text); \
-            fallback; \
-        }
-
 void ngx_log_error(int level, ngx_log_t *log, ngx_err_t err,
                    const char *fmt, ...);
 void ngx_log_error_core(int level, ngx_log_t *log, ngx_err_t err,
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 46deab4..10326bc 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -217,12 +217,6 @@
     } else {
         n = ngx_read_file(src->file, dst->pos, size, src->file_pos);
 
-if (n == 0) {
-ngx_log_debug(src->file->log, "READ: %qd:%qd %X:%X %X:%X" _
-              src->file_pos _ src->file_last _
-              dst->pos _ dst->last _ dst->start _ dst->end);
-}
-
         if (n == NGX_ERROR) {
             return n;
         }