/**
  * @covers LegacyLogger::shouldEmit
  * @dataProvider provideShouldEmit
  */
 public function testShouldEmit($level, $config, $expected)
 {
     $this->setMwGlobals('wgDebugLogGroups', array('fakechannel' => $config));
     $this->assertEquals($expected, LegacyLogger::shouldEmit('fakechannel', 'some message', $level, array()));
 }
 protected function write(array $record)
 {
     if ($this->useLegacyFilter && !LegacyLogger::shouldEmit($record['channel'], $record['message'], $record['level'], $record)) {
         // Do not write record if we are enforcing legacy rules and they
         // do not pass this message. This used to be done in isHandling(),
         // but Monolog 1.12.0 made a breaking change that removed access
         // to the needed channel and context information.
         return;
     }
     if ($this->sink === null) {
         $this->openSink();
     }
     $text = (string) $record['formatted'];
     if ($this->useUdp()) {
         // Clean it up for the multiplexer
         if ($this->prefix !== '') {
             $leader = $this->prefix === '{channel}' ? $record['channel'] : $this->prefix;
             $text = preg_replace('/^/m', "{$leader} ", $text);
             // Limit to 64KB
             if (strlen($text) > 65506) {
                 $text = substr($text, 0, 65506);
             }
             if (substr($text, -1) != "\n") {
                 $text .= "\n";
             }
         } elseif (strlen($text) > 65507) {
             $text = substr($text, 0, 65507);
         }
         socket_sendto($this->sink, $text, strlen($text), 0, $this->host, $this->port);
     } else {
         fwrite($this->sink, $text);
     }
 }