mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
new ini setting log_errors_max_len
@-New ini setting log_errors_max_len controls maximum length for error @ messages. Set it to 0 for infinite. Default is 1024 (old behaviour) (Marcus)
This commit is contained in:
parent
f140a8dd0d
commit
bd9cf79efb
21
main/main.c
21
main/main.c
@ -235,6 +235,7 @@ PHP_INI_BEGIN()
|
||||
STD_PHP_INI_BOOLEAN("ignore_user_abort", "0", PHP_INI_ALL, OnUpdateBool, ignore_user_abort, php_core_globals, core_globals)
|
||||
STD_PHP_INI_BOOLEAN("implicit_flush", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM,OnUpdateBool, implicit_flush, php_core_globals, core_globals)
|
||||
STD_PHP_INI_BOOLEAN("log_errors", "0", PHP_INI_ALL, OnUpdateBool, log_errors, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("log_errors_max_len", "1024", PHP_INI_ALL, OnUpdateInt, log_errors_max_len, php_core_globals, core_globals)
|
||||
STD_PHP_INI_BOOLEAN("ignore_repeated_errors", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_errors, php_core_globals, core_globals)
|
||||
STD_PHP_INI_BOOLEAN("ignore_repeated_source", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_source, php_core_globals, core_globals)
|
||||
STD_PHP_INI_BOOLEAN("magic_quotes_gpc", "1", PHP_INI_ALL, OnUpdateBool, magic_quotes_gpc, php_core_globals, core_globals)
|
||||
@ -420,15 +421,11 @@ PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC)
|
||||
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[ERROR_BUF_LEN];
|
||||
char *buffer;
|
||||
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;
|
||||
}
|
||||
buffer_len = vspprintf(&buffer, PG(log_errors_max_len), format, args);
|
||||
if (PG(ignore_repeated_errors)) {
|
||||
if (strncmp(last_error.buf, buffer, sizeof(last_error.buf))
|
||||
|| (!PG(ignore_repeated_source)
|
||||
@ -476,15 +473,16 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
|
||||
}
|
||||
|
||||
if (!module_initialized || PG(log_errors)) {
|
||||
char log_buffer[ERROR_BUF_LEN];
|
||||
char *log_buffer;
|
||||
|
||||
#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, ERROR_BUF_LEN, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno);
|
||||
spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno);
|
||||
php_log_err(log_buffer TSRMLS_CC);
|
||||
efree(log_buffer);
|
||||
}
|
||||
if (module_initialized && PG(display_errors)
|
||||
&& (!PG(during_request_startup) || PG(display_startup_errors))) {
|
||||
@ -547,13 +545,17 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
|
||||
case E_USER_ERROR:
|
||||
if (module_initialized) {
|
||||
zend_bailout();
|
||||
efree(buffer);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Log if necessary */
|
||||
if (!display) return;
|
||||
if (!display) {
|
||||
efree(buffer);
|
||||
return;
|
||||
}
|
||||
if (PG(track_errors) && EG(active_symbol_table)) {
|
||||
pval *tmp;
|
||||
|
||||
@ -564,6 +566,7 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
|
||||
Z_TYPE_P(tmp) = IS_STRING;
|
||||
zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(pval *), NULL);
|
||||
}
|
||||
efree(buffer);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -76,6 +76,7 @@ struct _php_core_globals {
|
||||
zend_bool display_errors;
|
||||
zend_bool display_startup_errors;
|
||||
zend_bool log_errors;
|
||||
int log_errors_max_len;
|
||||
zend_bool ignore_repeated_errors;
|
||||
zend_bool ignore_repeated_source;
|
||||
char *error_log;
|
||||
|
@ -257,6 +257,10 @@ display_startup_errors = Off
|
||||
; error displaying on production web sites.
|
||||
log_errors = Off
|
||||
|
||||
; Set maximum length of log_errors. In error_log information about the source is
|
||||
; added. The default is 1024 and 0 allows to not apply any maximum length at all.
|
||||
log_errors_max_len = 1024
|
||||
|
||||
; Do not log repeated messages. Repeated errors must occur in same file on same
|
||||
; line until ignore_repeated_source is set true.
|
||||
ignore_repeated_errors = Off
|
||||
|
@ -262,6 +262,10 @@ display_startup_errors = Off
|
||||
; error displaying on production web sites.
|
||||
log_errors = On
|
||||
|
||||
; Set maximum length of log_errors. In error_log information about the source is
|
||||
; added. The default is 1024 and 0 allows to not apply any maximum length at all.
|
||||
log_errors_max_len = 1024
|
||||
|
||||
; Do not log repeated messages. Repeated errors must occur in same file on same
|
||||
; line until ignore_repeated_source is set true.
|
||||
ignore_repeated_errors = Off
|
||||
|
Loading…
Reference in New Issue
Block a user