86 if (!extension_loaded(
'openssl')) {
100 if ($this->includeContextAndExtra && $this->useShortAttachment) {
140 'token' => $this->token,
141 'channel' => $this->channel,
142 'username' => $this->username,
144 'attachments' =>
array(),
147 if ($this->formatter) {
148 $message = $this->formatter->format($record);
153 if ($this->useAttachment) {
160 if ($this->useShortAttachment) {
161 $attachment[
'title'] = $record[
'level_name'];
164 $attachment[
'title'] =
'Message';
166 $attachment[
'fields'][] =
array(
168 'value' => $record[
'level_name'],
173 if ($this->includeContextAndExtra) {
174 if (!empty($record[
'extra'])) {
175 if ($this->useShortAttachment) {
176 $attachment[
'fields'][] =
array(
178 'value' => $this->
stringify($record[
'extra']),
179 'short' => $this->useShortAttachment,
183 foreach ($record[
'extra'] as $var => $val) {
184 $attachment[
'fields'][] =
array(
187 'short' => $this->useShortAttachment,
193 if (!empty($record[
'context'])) {
194 if ($this->useShortAttachment) {
195 $attachment[
'fields'][] =
array(
196 'title' =>
"Context",
197 'value' => $this->
stringify($record[
'context']),
198 'short' => $this->useShortAttachment,
202 foreach ($record[
'context'] as $var => $val) {
203 $attachment[
'fields'][] =
array(
206 'short' => $this->useShortAttachment,
218 if ($this->iconEmoji) {
219 $dataArray[
'icon_emoji'] =
":{$this->iconEmoji}:";
233 $header =
"POST /api/chat.postMessage HTTP/1.1\r\n";
234 $header .=
"Host: slack.com\r\n";
235 $header .=
"Content-Type: application/x-www-form-urlencoded\r\n";
236 $header .=
"Content-Length: " . strlen($content) .
"\r\n";
249 parent::write($record);
251 if (is_resource(
$res)) {
287 foreach ($fields as $var => $val) {
288 $string .= $var.
': '.$this->lineFormatter->stringify($val).
" | ";
291 $string = rtrim($string,
" |");
generateDataStream($record)
{}
prepareContentData($record)
Prepares content data.
const ERROR
Runtime errors.
Stores to any socket - uses fsockopen() or pfsockopen().
getAttachmentColor($level)
Returned a Slack message attachment color associated with provided level.
Sends notifications through Slack API.
catch(Exception $e) $message
__construct($token, $channel, $username='Monolog', $useAttachment=true, $iconEmoji=null, $level=Logger::CRITICAL, $bubble=true, $useShortAttachment=false, $includeContextAndExtra=false)
foreach($_POST as $key=> $value) $res
buildContent($record)
Builds the body of API call.
const WARNING
Exceptional occurrences that are not errors.
Exception can be thrown if an extension for an handler is missing.
Create styles array
The data for the language used.
const CRITICAL
Critical conditions.
buildHeader($content)
Builds the header of the API Call.
stringify($fields)
Stringifies an array of key/value pairs to be used in attachment fields.
closeSocket()
Close socket, if open.
const INFO
Interesting events.