'MediaWiki\\Linker\\LinkRenderer' => __DIR__ . '/includes/linker/LinkRenderer.php',
'MediaWiki\\Linker\\LinkRendererFactory' => __DIR__ . '/includes/linker/LinkRendererFactory.php',
'MediaWiki\\Linker\\LinkTarget' => __DIR__ . '/includes/linker/LinkTarget.php',
+ 'MediaWiki\\Logger\\ConsoleLogger' => __DIR__ . '/includes/debug/logger/ConsoleLogger.php',
+ 'MediaWiki\\Logger\\ConsoleSpi' => __DIR__ . '/includes/debug/logger/ConsoleSpi.php',
'MediaWiki\\Logger\\LegacyLogger' => __DIR__ . '/includes/debug/logger/LegacyLogger.php',
'MediaWiki\\Logger\\LegacySpi' => __DIR__ . '/includes/debug/logger/LegacySpi.php',
'MediaWiki\\Logger\\LoggerFactory' => __DIR__ . '/includes/debug/logger/LoggerFactory.php',
--- /dev/null
+<?php
+
+namespace MediaWiki\Logger;
+
+use Psr\Log\AbstractLogger;
+
+/**
+ * A logger which writes to the terminal. The output is supposed to be
+ * human-readable, and should be changed as necessary to better achieve that
+ * goal.
+ */
+class ConsoleLogger extends AbstractLogger {
+ public function __construct( $channel ) {
+ $this->channel = $channel;
+ }
+
+ public function log( $level, $message, array $context = [] ) {
+ fwrite( STDERR, "[$level] " .
+ LegacyLogger::format( $this->channel, $message, $context ) );
+ }
+}
--- /dev/null
+<?php
+namespace MediaWiki\Logger;
+
+class ConsoleSpi implements Spi {
+ public function __construct( $config = [] ) {
+ }
+
+ public function getLogger( $channel ) {
+ return new ConsoleLogger( $channel );
+ }
+}
* @ingroup Maintenance
*/
+use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\Logger\ConsoleSpi;
+
$optionsWithArgs = [ 'd' ];
require_once __DIR__ . "/commandLine.inc";
if ( isset( $options['d'] ) ) {
$d = $options['d'];
if ( $d > 0 ) {
- $wgDebugLogFile = '/dev/stdout';
+ LoggerFactory::registerProvider( new ConsoleSpi );
}
if ( $d > 1 ) {
$lb = wfGetLB();
* @author Gergő Tisza <tgr.huwiki@gmail.com>
*/
+use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\Logger\ConsoleSpi;
+
require_once __DIR__ . '/Maintenance.php';
/**
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
);
* 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)