From: Brion Vibber Date: Tue, 4 Apr 2006 05:53:21 +0000 (+0000) Subject: * Added $wgColorErrors: if set, database error messages will be highlighted when... X-Git-Tag: 1.6.0~45 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=afc2a705024077a9a321f629bcf76afeea851b46;p=lhc%2Fweb%2Fwiklou.git * Added $wgColorErrors: if set, database error messages will be highlighted when running command-line scripts in a Unix terminal. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 287363db5f..06d8d1a6e8 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -737,6 +737,8 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 5355) Include skin name and style JS settings in page source; fixes regression where Opera 6/7 and KHTML CSS fixes weren't applied when wikibits.js was moved up before user JS inclusion. +* Added $wgColorErrors: if set, database error messages will be highlighted + when running command-line scripts in a Unix terminal. === Caveats === diff --git a/includes/Database.php b/includes/Database.php index 57e68ea884..b7e09dadaa 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -447,7 +447,7 @@ class Database { * @param bool $tempIgnore */ function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) { - global $wgCommandLineMode, $wgFullyInitialised; + global $wgCommandLineMode, $wgFullyInitialised, $wgColorErrors; # Ignore errors during error handling to avoid infinite recursion $ignore = $this->ignoreErrors( true ); ++$this->mErrorCount; @@ -466,6 +466,10 @@ class Database { if ( !$wgCommandLineMode ) { $message = nl2br( $message ); } + if( $wgCommandLineMode && $wgColorErrors && !wfIsWindows() && posix_isatty(1) ) { + $color = 31; // bright red! + $message = "\x1b[1;{$color}m{$message}\x1b[0m"; + } wfDebugDieBacktrace( $message ); } else { // this calls wfAbruptExit() diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 5748f7aa69..091aa961ea 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -727,6 +727,13 @@ $wgDebugLogGroups = array(); */ $wgShowSQLErrors = false; +/** + * If true, some error messages will be colorized when running scripts on the + * command line; this can aid picking important things out when debugging. + * Ignored when running on Windows or when output is redirected to a file. + */ +$wgColorErrors = true; + /** * disable experimental dmoz-like category browsing. Output things like: * Encyclopedia > Music > Style of Music > Jazz