Re: cvs: php4 /main/main.c [[Re: [PHP-DEV] ErrorLog problem]]
| From: | (Marcus Boerger) | Date: | Sat, 30 Mar 2002 14:39:21 +0000 |
| Subject: | Re: cvs: php4 /main/main.c [[Re: [PHP-DEV] ErrorLog problem]] | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-81959@lists.php.net to get a copy of this message | ||
Try this patch. It does the same but it's a better solution.
But where is the configure variable to have your feature
disabled by default? - keep to discussion or say why you
ignore discussion points.
marcus
At 04:40 30.03.2002, you wrote: rootshell Fri Mar 29 23:13:29 2002 CET Modified files:cvs -z3 -q diff main\main.c (in directory S:\php4\) Index: main/main.c =================================================================== RCS file: /repository/php4/main/main.c,v retrieving revision 1.440 diff -u -r1.440 main.c/php4/main/main.cLog: lot of same errors are logged as one, cleans errorlog
--- main/main.c 19 Mar 2002 23:29:37 -0000 1.440+++ main/main.c 30 Mar 2002 14:32:05 -0000 @@ -84,6 +84,9 @@ PHPAPI int core_globals_id; #endif +#define ERROR_BUF_LEN 1024 +static char last_err_buf[ERROR_BUF_LEN]; + static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC); @@ -408,18 +411,21 @@ extended error handling function */ static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) {
- char buffer[1024];
- int buffer_len;
+ char buffer[ERROR_BUF_LEN];
+ int buffer_len, display;
TSRMLS_FETCH();
buffer_len = vsnprintf(buffer, sizeof(buffer)-1, format, args);
buffer[sizeof(buffer)-1]=0;
- if(buffer_len > sizeof(buffer) - 1 || buffer_len < 0) {
- buffer_len = sizeof(buffer) - 1;
+ if ((display = strncmp(buffer, last_err_buf, ERROR_BUF_LEN)) != 0) {
+ strncpy(last_err_buf, buffer, ERROR_BUF_LEN);
+ if(buffer_len > sizeof(buffer) - 1 || buffer_len < 0) {
+ buffer_len = sizeof(buffer) - 1;
+ }
}
-
+
/* display/log the error if necessary */
- if ((EG(error_reporting) & type || (type & E_CORE))
+ if (display && (EG(error_reporting) & type || (type & E_CORE))
&& (PG(log_errors) || PG(display_errors) || (!module_initialized))) {
char *error_type_str;
@@ -449,14 +455,14 @@
}
if (!module_initialized || PG(log_errors)) {
- char log_buffer[1024];
+ char log_buffer[ERROR_BUF_LEN];
#ifdef PHP_WIN32
if (type==E_CORE_ERROR || type==E_CORE_WARNING) {
MessageBox(NULL, buffer, error_type_str, MB_OK|ZEND_SERVICE_MB_STYLE);
}
#endif
- snprintf(log_buffer, 1024, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno);
+ snprintf(log_buffer, ERROR_BUF_LEN, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno);
php_log_err(log_buffer TSRMLS_CC);
}
if (module_initialized && PG(display_errors)
@@ -469,8 +475,8 @@
"<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%d</b><br />\n"
: "\n%s: %s in %s on line %d\n";
if (PG(xmlrpc_errors)) {
- error_format = do_alloca(1024);
- snprintf(error_format, 1023, "<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>%ld</int></value></member><member><name>faultString</name><value><string>%%s:%%s in %%s on line %%d</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number));
+ error_format = do_alloca(ERROR_BUF_LEN);
+ snprintf(error_format, ERROR_BUF_LEN-1, "<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>%ld</int></value></member><member><name>faultString</name><value><string>%%s:%%s in %%s on line %%d</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number));
}
if (prepend_string) {
@@ -526,6 +532,7 @@
}
/* Log if necessary */
+ if (!display) return;
if (PG(track_errors) && EG(active_symbol_table)) {
pval *tmp;