Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3730 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7387 invoked from network); 5 Aug 2003 07:14:51 -0000 Received: from unknown (HELO prp0.prp.physik.tu-darmstadt.de) (130.83.243.130) by pb1.pair.com with SMTP; 5 Aug 2003 07:14:51 -0000 Received: from prp0.prp.physik.tu-darmstadt.de (localhost [127.0.0.1]) by prp0.prp.physik.tu-darmstadt.de (8.12.3/8.12.3/SuSE Linux 0.6) with ESMTP id h757EmE7030765 for ; Tue, 5 Aug 2003 09:14:48 +0200 Received: (from swalk@localhost) by prp0.prp.physik.tu-darmstadt.de (8.12.3/8.12.3/Submit) id h757Emaq030764 for internals@lists.php.net; Tue, 5 Aug 2003 09:14:48 +0200 Date: Tue, 5 Aug 2003 09:14:48 +0200 To: internals@lists.php.net Message-ID: <20030805071448.GB29823@prp0.prp.physik.tu-darmstadt.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="x+6KMIRAuhnl3hBn" Content-Disposition: inline User-Agent: Mutt/1.3.27i Subject: [PATCH] Repost: html_errors more readable From: et@php.net (Stefan Walk) --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, A while ago I proposed a patch that improved html_errors, but i got no response from that, so i repost an improved version... The patch changes they way errors are displayed: 1) They are readable. The current version prints in black with no background at all, sometimes leading to black error messages on dark backgrounds - not very readable. Additionally, they have a fixed font size so they don't appear in a 4px font somewhere. 2) They are colorized. Notices, warnings, fatal errors and other errors get distinct colors for a better quick overview. 3) They look better ;) It uses CSS to format the error message nicely. The colors used are changeable by php.ini directives. Since many people just debug in their browser without using own error_handlers or append/prepend_strings, i think this is a nice addition that makes php more user-friendly. An example of how this looks can be found at: http://prp0.prp.physik.tu-darmstadt.de/~swalk/errors.htm Regards Stefan --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="error_reporting.txt" Index: main/main.c =================================================================== RCS file: /repository/php-src/main/main.c,v retrieving revision 1.562 diff -u -r1.562 main.c --- main/main.c 30 Jul 2003 16:15:03 -0000 1.562 +++ main/main.c 5 Aug 2003 06:02:39 -0000 @@ -340,6 +340,11 @@ STD_PHP_INI_BOOLEAN("allow_url_fopen", "1", PHP_INI_ALL, OnUpdateBool, allow_url_fopen, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("always_populate_raw_post_data", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, always_populate_raw_post_data, php_core_globals, core_globals) + PHP_INI_ENTRY("html_errors.notice_color", "#bfb", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("html_errors.warning_color", "#fea", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("html_errors.fatal_color", "#fbb", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("html_errors.other_color", "#fff", PHP_INI_ALL, NULL) + PHP_INI_END() /* }}} */ @@ -659,6 +664,7 @@ if (display && (EG(error_reporting) & type || (type & E_CORE)) && (PG(log_errors) || PG(display_errors) || (!module_initialized))) { char *error_type_str; + char *error_color_str; switch (type) { case E_ERROR: @@ -666,22 +672,27 @@ case E_COMPILE_ERROR: case E_USER_ERROR: error_type_str = "Fatal error"; + error_color_str = INI_STR("html_errors.fatal_color"); break; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_USER_WARNING: error_type_str = "Warning"; + error_color_str = INI_STR("html_errors.warning_color"); break; case E_PARSE: error_type_str = "Parse error"; + error_color_str = INI_STR("html_errors.other_color"); break; case E_NOTICE: case E_USER_NOTICE: error_type_str = "Notice"; + error_color_str = INI_STR("html_errors.notice_color"); break; default: error_type_str = "Unknown error"; + error_color_str = INI_STR("html_errors.other_color"); break; } @@ -705,10 +716,13 @@ } else { char *prepend_string = INI_STR("error_prepend_string"); char *append_string = INI_STR("error_append_string"); - char *error_format = PG(html_errors) ? - "%s
\n%s: %s in %s on line %d
\n%s" - : "%s\n%s: %s in %s on line %d\n%s"; - php_printf(error_format, STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); + if (PG(html_errors)) { + char *error_format = "%s\n
%s: %s in %s on line %d
\n%s"; + php_printf(error_format, STR_PRINT(prepend_string), error_color_str, error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); + } else { + char *error_format = "%s\n%s: %s in %s on line %d\n%s"; + php_printf(error_format, STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); + } } } #if ZEND_DEBUG --x+6KMIRAuhnl3hBn--