mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-08 14:16:42 +02:00
Making SlackHandler more extendable
This commit is contained in:
@@ -120,19 +120,32 @@ class SlackHandler extends SocketHandler
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function buildContent($record)
|
private function buildContent($record)
|
||||||
|
{
|
||||||
|
$dataArray = $this->prepareContentData($record);
|
||||||
|
|
||||||
|
return http_build_query($dataArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares content data
|
||||||
|
*
|
||||||
|
* @param array $record
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function prepareContentData($record)
|
||||||
{
|
{
|
||||||
$dataArray = array(
|
$dataArray = array(
|
||||||
'token' => $this->token,
|
'token' => $this->token,
|
||||||
'channel' => $this->channel,
|
'channel' => $this->channel,
|
||||||
'username' => $this->username,
|
'username' => $this->username,
|
||||||
'text' => '',
|
'text' => '',
|
||||||
'attachments' => array()
|
'attachments' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->useAttachment) {
|
if ($this->useAttachment) {
|
||||||
$attachment = array(
|
$attachment = array(
|
||||||
'fallback' => $record['message'],
|
'fallback' => $record['message'],
|
||||||
'color' => $this->getAttachmentColor($record['level'])
|
'color' => $this->getAttachmentColor($record['level'])
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->useShortAttachment) {
|
if ($this->useShortAttachment) {
|
||||||
@@ -173,7 +186,7 @@ class SlackHandler extends SocketHandler
|
|||||||
'title' => $var,
|
'title' => $var,
|
||||||
'value' => $val,
|
'value' => $val,
|
||||||
'short' => $this->useShortAttachment
|
'short' => $this->useShortAttachment
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,7 +205,7 @@ class SlackHandler extends SocketHandler
|
|||||||
'title' => $var,
|
'title' => $var,
|
||||||
'value' => $val,
|
'value' => $val,
|
||||||
'short' => $this->useShortAttachment
|
'short' => $this->useShortAttachment
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,8 +219,7 @@ class SlackHandler extends SocketHandler
|
|||||||
if ($this->iconEmoji) {
|
if ($this->iconEmoji) {
|
||||||
$dataArray['icon_emoji'] = ":{$this->iconEmoji}:";
|
$dataArray['icon_emoji'] = ":{$this->iconEmoji}:";
|
||||||
}
|
}
|
||||||
|
return $dataArray;
|
||||||
return http_build_query($dataArray);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user