summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/SAPI.h1
-rw-r--r--main/main.c48
-rw-r--r--sapi/aolserver/aolserver.c2
-rw-r--r--sapi/apache/mod_php4.c18
-rw-r--r--sapi/cgi/cgi_main.c10
-rw-r--r--sapi/isapi/php4isapi.c1
-rw-r--r--sapi/phttpd/phttpd.c1
-rw-r--r--sapi/roxen/roxen.c1
-rw-r--r--sapi/servlet/servlet.c1
-rw-r--r--sapi/thttpd/thttpd.c1
10 files changed, 50 insertions, 34 deletions
diff --git a/main/SAPI.h b/main/SAPI.h
index 7500b3ee20..60fc8efc6d 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -148,6 +148,7 @@ struct _sapi_module_struct {
char *(*read_cookies)(SLS_D);
void (*register_server_variables)(zval *track_vars_array ELS_DC SLS_DC PLS_DC);
+ void (*log_message)(char *message);
void (*default_post_reader)(char *content_type_dup SLS_DC);
};
diff --git a/main/main.c b/main/main.c
index e8706ac29f..3a1dc2e8e2 100644
--- a/main/main.c
+++ b/main/main.c
@@ -255,9 +255,6 @@ void php_log_err(char *log_message)
struct tm tmbuf;
time_t error_time;
PLS_FETCH();
-#if APACHE
- SLS_FETCH();
-#endif
/* Try to use the specified logging location. */
if (PG(error_log) != NULL) {
@@ -265,42 +262,25 @@ void php_log_err(char *log_message)
if (!strcmp(PG(error_log), "syslog")) {
syslog(LOG_NOTICE, log_message);
return;
- } else {
-#endif
- log_file = fopen(PG(error_log), "a");
- if (log_file != NULL) {
- time(&error_time);
- strftime(error_time_str, 128, "%d-%b-%Y %H:%M:%S", localtime_r(&error_time, &tmbuf));
- fprintf(log_file, "[%s] ", error_time_str);
- fprintf(log_file, log_message);
- fprintf(log_file, "\n");
- fclose(log_file);
- return;
- }
-#if HAVE_SYSLOG_H
}
#endif
+ log_file = fopen(PG(error_log), "a");
+ if (log_file != NULL) {
+ time(&error_time);
+ strftime(error_time_str, 128, "%d-%b-%Y %H:%M:%S", localtime_r(&error_time, &tmbuf));
+ fprintf(log_file, "[%s] ", error_time_str);
+ fprintf(log_file, log_message);
+ fprintf(log_file, "\n");
+ fclose(log_file);
+ return;
+ }
}
- /* Otherwise fall back to the default logging location. */
-#if APACHE
- if (SG(server_context)) {
-#if MODULE_MAGIC_NUMBER >= 19970831
- aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, log_message);
-#else
- log_error(log_message, ((requset_rec *) SG(server_context))->server);
-#endif
- } else {
- fprintf(stderr, log_message);
- fprintf(stderr, "\n");
- }
-#endif /*APACHE */
-#if CGI_BINARY
- if (php_header()) {
- fprintf(stderr, log_message);
- fprintf(stderr, "\n");
+ /* Otherwise fall back to the default logging location, if we have one */
+
+ if (sapi_module.log_message) {
+ sapi_module.log_message(log_message);
}
-#endif
}
diff --git a/sapi/aolserver/aolserver.c b/sapi/aolserver/aolserver.c
index 2b588dc1f2..eeb3b1c807 100644
--- a/sapi/aolserver/aolserver.c
+++ b/sapi/aolserver/aolserver.c
@@ -288,6 +288,7 @@ php_ns_startup(sapi_module_struct *sapi_module)
}
}
+
/* this structure is static (as in "it does not change") */
static sapi_module_struct sapi_module = {
@@ -309,6 +310,7 @@ static sapi_module_struct sapi_module = {
php_ns_sapi_read_cookies, /* read Cookies */
NULL, /* register server variables */
+ NULL, /* Log message */
STANDARD_SAPI_MODULE_PROPERTIES
};
diff --git a/sapi/apache/mod_php4.c b/sapi/apache/mod_php4.c
index 74bba3467e..c7ac6cd8c3 100644
--- a/sapi/apache/mod_php4.c
+++ b/sapi/apache/mod_php4.c
@@ -267,6 +267,23 @@ php_apache_startup(sapi_module_struct *sapi_module)
}
+static void php_apache_log_message(char *message)
+{
+ SLS_FETCH();
+
+ if (SG(server_context)) {
+#if MODULE_MAGIC_NUMBER >= 19970831
+ aplog_error(NULL, 0, APLOG_ERR | APLOG_NOERRNO, ((request_rec *) SG(server_context))->server, message);
+#else
+ log_error(message, ((requset_rec *) SG(server_context))->server);
+#endif
+ } else {
+ fprintf(stderr, message);
+ fprintf(stderr, "\n");
+ }
+}
+
+
static sapi_module_struct sapi_module = {
"Apache", /* name */
@@ -287,6 +304,7 @@ static sapi_module_struct sapi_module = {
sapi_apache_read_cookies, /* read Cookies */
sapi_apache_register_server_variables, /* register server variables */
+ php_apache_log_message, /* Log message */
STANDARD_SAPI_MODULE_PROPERTIES
};
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index d942d264a8..b0634c2192 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -159,6 +159,15 @@ static void sapi_cgi_register_variables(zval *track_vars_array ELS_DC SLS_DC PLS
}
+static void sapi_cgi_log_message(char *message)
+{
+ if (php_header()) {
+ fprintf(stderr, message);
+ fprintf(stderr, "\n");
+ }
+}
+
+
static sapi_module_struct sapi_module = {
"CGI", /* name */
@@ -178,6 +187,7 @@ static sapi_module_struct sapi_module = {
sapi_cgi_read_cookies, /* read Cookies */
sapi_cgi_register_variables, /* register server variables */
+ sapi_cgi_log_message, /* Log message */
STANDARD_SAPI_MODULE_PROPERTIES
};
diff --git a/sapi/isapi/php4isapi.c b/sapi/isapi/php4isapi.c
index 6db380b675..83e8c04ad2 100644
--- a/sapi/isapi/php4isapi.c
+++ b/sapi/isapi/php4isapi.c
@@ -358,6 +358,7 @@ static sapi_module_struct sapi_module = {
sapi_isapi_read_cookies, /* read Cookies */
sapi_isapi_register_server_variables, /* register server variables */
+ NULL, /* Log message */
STANDARD_SAPI_MODULE_PROPERTIES
};
diff --git a/sapi/phttpd/phttpd.c b/sapi/phttpd/phttpd.c
index 57d14e9639..a766816899 100644
--- a/sapi/phttpd/phttpd.c
+++ b/sapi/phttpd/phttpd.c
@@ -180,6 +180,7 @@ static sapi_module_struct sapi_module = {
php_phttpd_sapi_read_cookies, /* read Cookies */
NULL, /* register server variables */
+ NULL, /* Log message */
STANDARD_SAPI_MODULE_PROPERTIES
};
diff --git a/sapi/roxen/roxen.c b/sapi/roxen/roxen.c
index 9fb78b5a93..7c797667e6 100644
--- a/sapi/roxen/roxen.c
+++ b/sapi/roxen/roxen.c
@@ -534,6 +534,7 @@ static sapi_module_struct sapi_module = {
php_roxen_sapi_read_cookies, /* read Cookies */
NULL, /* register server variables */
+ NULL, /* Log message */
STANDARD_SAPI_MODULE_PROPERTIES
diff --git a/sapi/servlet/servlet.c b/sapi/servlet/servlet.c
index 36e8c81360..463baeaecb 100644
--- a/sapi/servlet/servlet.c
+++ b/sapi/servlet/servlet.c
@@ -236,6 +236,7 @@ static sapi_module_struct sapi_module = {
sapi_servlet_read_cookies, /* read Cookies */
NULL, /* register server variables */
+ NULL, /* Log message */
STANDARD_SAPI_MODULE_PROPERTIES
};
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c
index 81726c2205..3633475129 100644
--- a/sapi/thttpd/thttpd.c
+++ b/sapi/thttpd/thttpd.c
@@ -119,6 +119,7 @@ static sapi_module_struct sapi_module = {
sapi_thttpd_read_cookies,
NULL, /* register server variables */
+ NULL, /* Log message */
STANDARD_SAPI_MODULE_PROPERTIES
};