mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-19 15:49:19 +02:00
Added emoji support as per slack api doc: https://api.slack.com/methods/chat.postMessage
This commit is contained in:
@@ -38,6 +38,12 @@ class SlackHandler extends SocketHandler
|
||||
* @var string
|
||||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* Emoji icon name
|
||||
* @var string
|
||||
*/
|
||||
private $iconEmoji;
|
||||
|
||||
/**
|
||||
* Whether the message should be added to Slack as attachment (plain text otherwise)
|
||||
@@ -53,7 +59,7 @@ class SlackHandler extends SocketHandler
|
||||
* @param int $level The minimum logging level at which this handler will be triggered
|
||||
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
||||
*/
|
||||
public function __construct($token, $channel, $username = 'Monolog', $useAttachment = true, $level = Logger::CRITICAL, $bubble = true)
|
||||
public function __construct($token, $channel, $username = 'Monolog', $iconEmoji = 'alien', $useAttachment = true, $level = Logger::CRITICAL, $bubble = true)
|
||||
{
|
||||
if (!extension_loaded('openssl')) {
|
||||
throw new MissingExtensionException('The OpenSSL PHP extension is required to use the SlackHandler');
|
||||
@@ -64,6 +70,7 @@ class SlackHandler extends SocketHandler
|
||||
$this->token = $token;
|
||||
$this->channel = $channel;
|
||||
$this->username = $username;
|
||||
$this->iconEmoji = $iconEmoji;
|
||||
$this->useAttachment = $useAttachment;
|
||||
}
|
||||
|
||||
@@ -92,6 +99,7 @@ class SlackHandler extends SocketHandler
|
||||
'token' => $this->token,
|
||||
'channel' => $this->channel,
|
||||
'username' => $this->username,
|
||||
'icon_emoji' => ":{$this->iconEmoji}:",
|
||||
'text' => '',
|
||||
'attachments' => array()
|
||||
);
|
||||
|
Reference in New Issue
Block a user