Constants

COLOR_DANGER

COLOR_DANGER = 'danger'

COLOR_WARNING

COLOR_WARNING = 'warning'

COLOR_GOOD

COLOR_GOOD = 'good'

COLOR_DEFAULT

COLOR_DEFAULT = '#e3e4e6'

Properties

$channel

$channel : string|null

Slack channel (encoded ID or name)

Type

string|null

$username

$username : string|null

Name of a bot

Type

string|null

$userIcon

$userIcon : string

User icon e.g. 'ghost', 'http://example.com/user.png'

Type

string

$useAttachment

$useAttachment : boolean

Whether the message should be added to Slack as attachment (plain text otherwise)

Type

boolean

$useShortAttachment

$useShortAttachment : boolean

Whether the the context/extra messages added to Slack as attachments are in a short style

Type

boolean

$includeContextAndExtra

$includeContextAndExtra : boolean

Whether the attachment should include context and extra data

Type

boolean

$excludeFields

$excludeFields : array

Dot separated list of fields to exclude from slack message. E.g. ['context.field1', 'extra.field2']

Type

array

Methods

__construct()

__construct(  $channel = null,   $username = null,   $useAttachment = true,   $userIcon = null,   $useShortAttachment = false,   $includeContextAndExtra = false, array  $excludeFields = array(), \Monolog\Formatter\FormatterInterface  $formatter = null) 

Parameters

$channel
$username
$useAttachment
$userIcon
$useShortAttachment
$includeContextAndExtra
array $excludeFields
\Monolog\Formatter\FormatterInterface $formatter

getSlackData()

getSlackData(array  $record) 

Parameters

array $record

getAttachmentColor()

getAttachmentColor(integer  $level) : string

Returned a Slack message attachment color associated with provided level.

Parameters

integer $level

Returns

string

stringify()

stringify(array  $fields) : string

Stringifies an array of key/value pairs to be used in attachment fields

Parameters

array $fields

Returns

string

generateAttachmentField()

generateAttachmentField(string  $title,   $value) : array

Generates attachment field

Parameters

string $title
$value

Returns

array

generateAttachmentFields()

generateAttachmentFields(array  $data) : array

Generates a collection of attachment fields from array

Parameters

array $data

Returns

array

excludeFields()

excludeFields(array  $record) : array

Get a copy of record with fields excluded according to $this->excludeFields

Parameters

array $record

Returns

array