1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-13 00:24:10 +02:00

Use text and title fields for SlackHandler

According to slack documentation (https://api.slack.com/docs/attachments),  an attachment may have a title and a text. The log message and title should use these fields. One of the benefits of using these two properties instead of adding a field is that it's shortened (with a "show more" button) and expandable by slack. It adds a bit of hierarchy in the attachement. Message is the content. Extra and context are additional fields.
This commit is contained in:
raph
2015-09-17 09:52:52 +02:00
parent ec7f7001bd
commit 976259bb5b

View File

@@ -145,29 +145,20 @@ class SlackHandler extends SocketHandler
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']),
'fields' => array()
); );
if ($this->useShortAttachment) { if ($this->useShortAttachment) {
$attachment['fields'] = array( $attachment['title'] = $record['level_name'];
array( $attachment['text'] = $record['message'];
'title' => $record['level_name'],
'value' => $record['message'],
'short' => false
)
);
} else { } else {
$attachment['fields'] = array( $attachment['title'] = 'Message';
array( $attachment['text'] = $record['message'];
'title' => 'Message', $attachment['fields'][] = array(
'value' => $record['message'], 'title' => 'Level',
'short' => false 'value' => $record['level_name'],
), 'short' => true
array(
'title' => 'Level',
'value' => $record['level_name'],
'short' => true
)
); );
} }