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|null

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

Type

string|null

$useAttachment

$useAttachment : bool

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

Type

bool

$useShortAttachment

$useShortAttachment : bool

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

Type

bool

$includeContextAndExtra

$includeContextAndExtra : bool

Whether the attachment should include context and extra data

Type

bool

$excludeFields

$excludeFields : string[]

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

Type

string[]

$formatter

$formatter : ?\Monolog\Formatter\FormatterInterface

Type

FormatterInterface

$normalizerFormatter

$normalizerFormatter : \Monolog\Formatter\NormalizerFormatter

Type

NormalizerFormatter

Methods

__construct()

__construct(?string  $channel = null, ?string  $username = null, bool  $useAttachment = true, ?string  $userIcon = null, bool  $useShortAttachment = false, bool  $includeContextAndExtra = false, string[]  $excludeFields = array(), \Monolog\Formatter\FormatterInterface  $formatter = null) : mixed

Parameters

?string $channel
?string $username
bool $useAttachment
?string $userIcon
bool $useShortAttachment
bool $includeContextAndExtra
string[] $excludeFields
\Monolog\Formatter\FormatterInterface $formatter

Returns

mixed —

getSlackData()

getSlackData(array  $record) : array

Returns required data in format that Slack is expecting.

Parameters

array $record

Returns

array —

getAttachmentColor()

getAttachmentColor(int  $level) : string

Returns a Slack message attachment color associated with provided level.

Parameters

int $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 —

setChannel()

setChannel(?string  $channel = null) : static

Channel used by the bot when posting

Parameters

?string $channel

Returns

static —

setUsername()

setUsername(?string  $username = null) : static

Username used by the bot when posting

Parameters

?string $username

Returns

static —

useAttachment()

useAttachment(bool  $useAttachment = true) : self

Parameters

bool $useAttachment

Returns

self —

setUserIcon()

setUserIcon(?string  $userIcon = null) : self

Parameters

?string $userIcon

Returns

self —

useShortAttachment()

useShortAttachment(bool  $useShortAttachment = false) : self

Parameters

bool $useShortAttachment

Returns

self —

includeContextAndExtra()

includeContextAndExtra(bool  $includeContextAndExtra = false) : self

Parameters

bool $includeContextAndExtra

Returns

self —

excludeFields()

excludeFields(string[]  $excludeFields = []) : self

Parameters

string[] $excludeFields

Returns

self —

setFormatter()

setFormatter(?\Monolog\Formatter\FormatterInterface  $formatter = null) : self

Parameters

?\Monolog\Formatter\FormatterInterface $formatter

Returns

self —

generateAttachmentField()

generateAttachmentField(string  $title, string|array  $value) : array

Generates attachment field

Parameters

string $title
string|array $value

Returns

array —

generateAttachmentFields()

generateAttachmentFields(array  $data) : array

Generates a collection of attachment fields from array

Parameters

array $data

Returns

array —

removeExcludedFields()

removeExcludedFields(array  $record) : array

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

Parameters

array $record

Returns

array —