/**
  * Formats a log record.
  *
  * @param array $record A record to format
  *
  * @return mixed The formatted record
  */
 public function format(array $record)
 {
     $formattedRecord = $this->formatter->format($record);
     if (is_array($formattedRecord)) {
         list($channel, $message, $backtrace, $loglevel) = $formattedRecord;
         $formattedRecord = [$channel, $this->formatterPrefix . $message, $backtrace, $loglevel];
     } else {
         $formattedRecord = $this->formatterPrefix . $formattedRecord;
     }
     return $formattedRecord;
 }
Ejemplo n.º 2
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.º 3
0
 /**
  * @override
  * @inheritDoc
  */
 public function format(array $record)
 {
     return $this->model->format($record);
 }
 public function format(array $record)
 {
     return $this->formatter->format($this->addAdditionalInfo($record));
 }