From 7ab9e6ed0c95ae18a682d3ba3cc35966fdac0fbd Mon Sep 17 00:00:00 2001 From: Bryan Davis Date: Sun, 22 Mar 2015 16:54:06 -0600 Subject: [PATCH] Remove MWLoggerMonologSamplingHandler The Monolog\Handler\SamlingHandler class available since Monolog v1.12.0 is an upstreamed equivalent of MWLoggerMonologSamplingHandler. Requires: I8790da95fd658234e35b2d846af35993ebcd80e9 Change-Id: I3841cbab95382a66098d90f5570fa0bf3521578a --- autoload.php | 1 - .../debug/logger/monolog/SamplingHandler.php | 123 ------------------ 2 files changed, 124 deletions(-) delete mode 100644 includes/debug/logger/monolog/SamplingHandler.php diff --git a/autoload.php b/autoload.php index faa929cbed..dcd787972f 100644 --- a/autoload.php +++ b/autoload.php @@ -705,7 +705,6 @@ $wgAutoloadLocalClasses = array( 'MWLoggerMonologHandler' => __DIR__ . '/includes/debug/logger/monolog/Handler.php', 'MWLoggerMonologLegacyFormatter' => __DIR__ . '/includes/debug/logger/monolog/LegacyFormatter.php', 'MWLoggerMonologProcessor' => __DIR__ . '/includes/debug/logger/monolog/Processor.php', - 'MWLoggerMonologSamplingHandler' => __DIR__ . '/includes/debug/logger/monolog/SamplingHandler.php', 'MWLoggerMonologSpi' => __DIR__ . '/includes/debug/logger/monolog/Spi.php', 'MWLoggerMonologSyslogHandler' => __DIR__ . '/includes/debug/logger/monolog/SyslogHandler.php', 'MWLoggerNullSpi' => __DIR__ . '/includes/debug/logger/NullSpi.php', diff --git a/includes/debug/logger/monolog/SamplingHandler.php b/includes/debug/logger/monolog/SamplingHandler.php deleted file mode 100644 index a9f83b055f..0000000000 --- a/includes/debug/logger/monolog/SamplingHandler.php +++ /dev/null @@ -1,123 +0,0 @@ - 'MWLoggerMonologSpi', - * 'args' => array( array( - * 'handlers' => array( - * 'some-handler' => array( ... ), - * 'sampled-some-handler' => array( - * 'class' => 'MWLoggerMonologSamplingHandler', - * 'args' => array( - * function() { - * return MWLoggerFactory::getProvider()->getHandler( 'some-handler'); - * }, - * 2, // emit logs with a 1:2 chance - * ), - * ), - * ), - * ) ), - * ); - * @endcode - * - * A sampled event stream can be useful for logging high frequency events in - * a production environment where you only need an idea of what is happening - * and are not concerned with capturing every occurence. Since the decision to - * handle or not handle a particular event is determined randomly, the - * resulting sampled log is not guaranteed to contain 1/N of the events that - * occurred in the application but based on [[Law of large numbers]] it will - * tend to be close to this ratio with a large number of attempts. - * - * @since 1.25 - * @author Bryan Davis - * @copyright © 2014 Bryan Davis and Wikimedia Foundation. - */ -class MWLoggerMonologSamplingHandler implements HandlerInterface { - - /** - * @var HandlerInterface $delegate - */ - protected $delegate; - - /** - * @var int $factor - */ - protected $factor; - - /** - * @param HandlerInterface $handler Wrapped handler - * @param int $factor Sample factor - */ - public function __construct( HandlerInterface $handler, $factor ) { - $this->delegate = $handler; - $this->factor = $factor; - } - - public function isHandling( array $record ) { - return $this->delegate->isHandling( $record ); - } - - public function handle( array $record ) { - if ( $this->isHandling( $record ) - && mt_rand( 1, $this->factor ) === 1 - ) { - return $this->delegate->handle( $record ); - } - return false; - } - - public function handleBatch( array $records ) { - foreach ( $records as $record ) { - $this->handle( $record ); - } - } - - public function pushProcessor( $callback ) { - $this->delegate->pushProcessor( $callback ); - return $this; - } - - public function popProcessor() { - return $this->delegate->popProcessor(); - } - - public function setFormatter( FormatterInterface $formatter ) { - $this->delegate->setFormatter( $formatter ); - return $this; - } - - public function getFormatter() { - return $this->delegate->getFormatter(); - } - -} -- 2.20.1