public function formatBatch(array $records)
 {
     foreach ($records as $key => $value) {
         $records[$key] = $this->addAdditionalInfo($value);
     }
     return $this->formatter->formatBatch($records);
 }
 public function testHandleAndWriteWithUnavailableProducer()
 {
     $testRecord = array('level' => Logger::INFO, 'testmessage' => 'testmessage', 'datetime' => new \DateTime(), 'extra' => array(), 'formatted' => array());
     $testProperties = array('application_headers' => array("x-riak-target-vnode" => array("S", $this->vNode)));
     $this->formatterMock->expects($this->once())->method('format')->with($testRecord)->will($this->returnValue(array()));
     $this->messageProducerMock->expects($this->once())->method('publish')->with(json_encode($testRecord), $this->routingKey, $testProperties)->will($this->throwException(new \ErrorException('AMQPConnection failed')));
     $this->rabbitMqHandler->addAdditionalProperties($testProperties);
     $this->rabbitMqHandler->setFormatter($this->formatterMock);
     $this->assertFalse($this->rabbitMqHandler->handle($testRecord));
     $this->assertTrue($this->rabbitMqHandler->getBubble());
 }
Ejemplo n.º 3
0
 public function getSlackData(array $record)
 {
     $dataArray = array('username' => $this->username, 'text' => '');
     if ($this->channel) {
         $dataArray['channel'] = $this->channel;
     }
     if ($this->formatter) {
         $message = $this->formatter->format($record);
     } else {
         $message = $record['message'];
     }
     if ($this->useAttachment) {
         $attachment = array('fallback' => $message, 'text' => $message, 'color' => $this->getAttachmentColor($record['level']), 'fields' => array());
         if ($this->useShortAttachment) {
             $attachment['title'] = $record['level_name'];
         } else {
             $attachment['title'] = 'Message';
             $attachment['fields'][] = $this->generateAttachmentField('Level', $record['level_name'], true);
         }
         if ($this->includeContextAndExtra) {
             foreach (array('extra', 'context') as $key) {
                 if (empty($record[$key])) {
                     continue;
                 }
                 if ($this->useShortAttachment) {
                     $attachment['fields'][] = $this->generateAttachmentField(ucfirst($key), $this->stringify($record[$key]), true);
                 } else {
                     // Add all extra fields as individual fields in attachment
                     $attachment['fields'] = array_merge($attachment['fields'], $this->generateAttachmentFields($record[$key]));
                 }
             }
         }
         $dataArray['attachments'] = array($attachment);
     } else {
         $dataArray['text'] = $message;
     }
     if ($this->iconEmoji) {
         $dataArray['icon_emoji'] = ":{$this->iconEmoji}:";
     }
     return $dataArray;
 }
Ejemplo n.º 4
0
 /**
  * @override
  * @inheritDoc
  */
 public function formatBatch(array $records)
 {
     return $this->model->formatBatch($records);
 }