diff options
author | Tim Starling <tstarling@wikimedia.org> | 2017-04-28 09:56:38 +1000 |
---|---|---|
committer | Tim Starling <tstarling@wikimedia.org> | 2017-04-28 10:05:05 +1000 |
commit | a59ed5f3de94a491b669c51d4f60529108b85b4b (patch) | |
tree | 66ce2d005121d6e9ac2190490d27839dde983198 /maintenance/shell.php | |
parent | f8ac9bb2e6a28c0623a4aa5289c24de8394d9fae (diff) | |
download | mediawikicore-a59ed5f3de94a491b669c51d4f60529108b85b4b.tar.gz mediawikicore-a59ed5f3de94a491b669c51d4f60529108b85b4b.zip |
Add ConsoleLogger, use it for eval.php -d
eval.php previously set $wgDebugLogFile to /dev/stdout. This had the
following problems:
* It doesn't work if the maintenance script is executed via sudo, since
/dev/stdout is typically owned by the original user, so MW can't open
it. Using php://stdout worked on HHVM but not PHP.
* Setting $wgDebugLogFile has no effect if the wiki uses MonologSpi.
* Setting $wgDebugLogFile has no effect on channels configured with
$wgDebugLogGroups.
* stderr is a more appropriate place to send logging output.
* Writing to configuration variables is discouraged.
So, add ConsoleSpi, which is a very simple logging service provider
which sends all messages to stderr. This should be suitable for
debugging with eval.php or shell.php in WMF production or beta.
Change-Id: Ib0d6ce45e0cbecd58263fc4e360c63d4149acb3a
Diffstat (limited to 'maintenance/shell.php')
-rw-r--r-- | maintenance/shell.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/maintenance/shell.php b/maintenance/shell.php index 47ef8045b13d..9f2306fc3e66 100644 --- a/maintenance/shell.php +++ b/maintenance/shell.php @@ -34,6 +34,9 @@ * @author Gergő Tisza <tgr.huwiki@gmail.com> */ +use MediaWiki\Logger\LoggerFactory; +use MediaWiki\Logger\ConsoleSpi; + require_once __DIR__ . '/Maintenance.php'; /** @@ -46,7 +49,7 @@ class MediaWikiShell extends Maintenance { parent::__construct(); $this->addOption( 'd', 'For back compatibility with eval.php. ' . - '0 send debug to stdout. ' . + '0 send debug to stderr. ' . 'With 1 additionally initialize database with debugging ', false, true ); @@ -77,11 +80,9 @@ class MediaWikiShell extends Maintenance { * For back compatibility with eval.php */ protected function setupLegacy() { - global $wgDebugLogFile; - $d = intval( $this->getOption( 'd' ) ); if ( $d > 0 ) { - $wgDebugLogFile = 'php://stdout'; + LoggerFactory::registerProvider( new ConsoleSpi ); } if ( $d > 1 ) { # Set DBO_DEBUG (equivalent of $wgDebugDumpSql) |