51 public function __construct(
$token, $channel, $username = null, $useAttachment =
true, $iconEmoji = null,
$level =
Logger::CRITICAL,
$bubble =
true, $useShortAttachment =
false, $includeContextAndExtra =
false, array $excludeFields = array())
53 if (!extension_loaded(
'openssl')) {
65 $includeContextAndExtra,
106 return http_build_query($dataArray);
117 $dataArray = $this->slackRecord->getSlackData($record);
120 if (!empty($dataArray[
'attachments'])) {
121 $dataArray[
'attachments'] = json_encode($dataArray[
'attachments']);
135 $header =
"POST /api/chat.postMessage HTTP/1.1\r\n";
136 $header .=
"Host: slack.com\r\n";
137 $header .=
"Content-Type: application/x-www-form-urlencoded\r\n";
138 $header .=
"Content-Length: " . strlen($content) .
"\r\n";
149 protected function write(array $record)
164 if (is_resource(
$res)) {
181 'SlackHandler::getAttachmentColor() is deprecated. Use underlying SlackRecord instead.',
185 return $this->slackRecord->getAttachmentColor(
$level);
198 'SlackHandler::stringify() is deprecated. Use underlying SlackRecord instead.',
202 return $this->slackRecord->stringify($fields);
207 parent::setFormatter($formatter);
208 $this->slackRecord->setFormatter($formatter);
generateDataStream($record)
{}
prepareContentData($record)
Prepares content data.
Stores to any socket - uses fsockopen() or pfsockopen().
finalizeWrite()
Finalizes the request by reading some bytes and then closing the socket.
getAttachmentColor($level)
Returned a Slack message attachment color associated with provided level.
Sends notifications through Slack API.
getFormatter()
Gets the formatter.
foreach($_POST as $key=> $value) $res
buildContent($record)
Builds the body of API call.
__construct($token, $channel, $username=null, $useAttachment=true, $iconEmoji=null, $level=Logger::CRITICAL, $bubble=true, $useShortAttachment=false, $includeContextAndExtra=false, array $excludeFields=array())
Slack record utility helping to log to Slack webhooks or API.
Exception can be thrown if an extension for an handler is missing.
const CRITICAL
Critical conditions.
buildHeader($content)
Builds the header of the API Call.
setFormatter(FormatterInterface $formatter)
Sets the formatter.
stringify($fields)
Stringifies an array of key/value pairs to be used in attachment fields.
closeSocket()
Close socket, if open.