]> granicus.if.org Git - apache/commitdiff
Add support for pool to log_error_core. Also add ap_log_perror to allow
authorRyan Bloom <rbb@apache.org>
Thu, 20 Apr 2000 16:25:40 +0000 (16:25 +0000)
committerRyan Bloom <rbb@apache.org>
Thu, 20 Apr 2000 16:25:40 +0000 (16:25 +0000)
logging without either a request or server _rec.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85002 13f79535-47bb-0310-9956-ffa450edef68

include/http_log.h
server/log.c

index 265563c0be6772408fcf18efbf5bc202e5adc86f..f89831a3fca3002c196643d92f010fbd4d64b5b7 100644 (file)
@@ -111,18 +111,22 @@ extern "C" {
 
 void ap_open_logs (server_rec *, ap_pool_t *p);
 
-/* The two primary logging functions, ap_log_error and ap_log_rerror,
- * use a printf style format string to build the log message.  It is
- * VERY IMPORTANT that you not include any raw data from the network,
- * such as the request-URI or request header fields, within the format
- * string.  Doing so makes the server vulnerable to a denial-of-service
- * attack and other messy behavior.  Instead, use a simple format string
+/* The three primary logging functions, ap_log_error, ap_log_rerror, and 
+ * ap_log_perror use a printf style format string to build the log message.  
+ * It is VERY IMPORTANT that you not include any raw data from the network, 
+ * such as the request-URI or request header fields, within the format 
+ * string.  Doing so makes the server vulnerable to a denial-of-service 
+ * attack and other messy behavior.  Instead, use a simple format string 
  * like "%s", followed by the string containing the untrusted data.
  */
 API_EXPORT(void) ap_log_error(const char *file, int line, int level, 
                              ap_status_t status, const server_rec *s, 
                              const char *fmt, ...)
                            __attribute__((format(printf,6,7)));
+API_EXPORT(void) ap_log_perror(const char *file, int line, int level, 
+                             ap_status_t status, ap_pool_t *p, 
+                             const char *fmt, ...)
+                           __attribute__((format(printf,6,7)));
 API_EXPORT(void) ap_log_rerror(const char *file, int line, int level, 
                                ap_status_t status, const request_rec *s, 
                                const char *fmt, ...)
index ef4f0c50a0deba772e9d0b1e6e8b1df4010ee78c..3139e24c72cb6ff4f7a4fcc6c06071683b390584 100644 (file)
@@ -312,7 +312,8 @@ API_EXPORT(void) ap_error_log2stderr(server_rec *s) {
 
 static void log_error_core(const char *file, int line, int level, 
                            ap_status_t status, const server_rec *s, 
-                           const request_rec *r, const char *fmt, va_list args)
+                           const request_rec *r, ap_pool_t *pool,
+                           const char *fmt, va_list args)
 {
     char errstr[MAX_STRING_LEN + 1];    /* + 1 to have room for '\n' */
     size_t len;
@@ -408,11 +409,20 @@ static void log_error_core(const char *file, int line, int level,
        len += ap_snprintf(errstr + len, MAX_STRING_LEN - len,
                "[client %s] ", r->connection->remote_ip);
     }
-    /* XXX - need an APRized strerror() */
     if (!(level & APLOG_NOERRNO)
        && (status != 0)) {
+        ap_pool_t *p;
+        if (r) {
+            p = r->pool;
+        }
+        else if (s) {
+            p = s->process->pool;
+        }
+        else {
+            p = pool;
+        }
        len += ap_snprintf(errstr + len, MAX_STRING_LEN - len,
-               "(%d)%s: ", status, strerror(status));
+               "(%d)%s: ", status, ap_strerror(status, p));
     }
 
     len += ap_vsnprintf(errstr + len, MAX_STRING_LEN - len, fmt, args);
@@ -441,7 +451,18 @@ API_EXPORT(void) ap_log_error(const char *file, int line, int level,
     va_list args;
 
     va_start(args, fmt);
-    log_error_core(file, line, level, status, s, NULL, fmt, args);
+    log_error_core(file, line, level, status, s, NULL, NULL, fmt, args);
+    va_end(args);
+}
+
+API_EXPORT(void) ap_log_perror(const char *file, int line, int level,
+                             ap_status_t status, ap_pool_t *p, 
+                              const char *fmt, ...)
+{
+    va_list args;
+
+    va_start(args, fmt);
+    log_error_core(file, line, level, status, NULL, NULL, p, fmt, args);
     va_end(args);
 }
 
@@ -452,7 +473,7 @@ API_EXPORT(void) ap_log_rerror(const char *file, int line, int level,
     va_list args;
 
     va_start(args, fmt);
-    log_error_core(file, line, level, status, r->server, r, fmt, args);
+    log_error_core(file, line, level, status, r->server, r, NULL, fmt, args);
     /*
      * IF the error level is 'warning' or more severe,
      * AND there isn't already error text associated with this request,
@@ -537,7 +558,7 @@ API_EXPORT(void) ap_log_printf(const server_rec *s, const char *fmt, ...)
     va_list args;
     
     va_start(args, fmt);
-    log_error_core(APLOG_MARK, APLOG_ERR, errno, s, NULL, fmt, args);
+    log_error_core(APLOG_MARK, APLOG_ERR, errno, s, NULL, NULL, fmt, args);
     va_end(args);
 }