Slack record utility helping to log to Slack webhooks or API.

CloneableInstantiable
Constants
public Monolog\Handler\Slack\SlackRecord::COLOR_DANGER = 'danger'
public Monolog\Handler\Slack\SlackRecord::COLOR_DEFAULT = '#e3e4e6'
public Monolog\Handler\Slack\SlackRecord::COLOR_GOOD = 'good'
public Monolog\Handler\Slack\SlackRecord::COLOR_WARNING = 'warning'
Methods
public __construct(?string $channel = NULL, ?string $username = NULL, bool $useAttachment = true, ?string $userIcon = NULL, bool $useShortAttachment = false, bool $includeContextAndExtra = false, array $excludeFields = [], ?Monolog\Formatter\FormatterInterface $formatter = NULL)
public excludeFields(array $excludeFields = []) : self
public getAttachmentColor(int $level) : string
 

Returns a Slack message attachment color associated with
provided level.

public getSlackData(array $record) : array
 

Returns required data in format that Slack
is expecting.

public includeContextAndExtra(bool $includeContextAndExtra = false) : self
public setChannel(?string $channel = NULL) : self
 

Channel used by the bot when posting

  • return SlackHandler
public setFormatter(?Monolog\Formatter\FormatterInterface $formatter = NULL) : self
public setUserIcon(?string $userIcon = NULL) : self
public setUsername(?string $username = NULL) : self
 

Username used by the bot when posting

  • return SlackHandler
public stringify(array $fields) : string
 

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

public useAttachment(bool $useAttachment = true) : self
public useShortAttachment(bool $useShortAttachment = false) : self
Properties
private $channel
 

Slack channel (encoded ID or name)

  • var string|null
private $excludeFields
 

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

  • var array
private $formatter
 
  • var FormatterInterface
private $includeContextAndExtra
 

Whether the attachment should include context and extra data

  • var bool
private $normalizerFormatter
 
  • var NormalizerFormatter
private $useAttachment
 

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

  • var bool
private $userIcon
 

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

  • var string|null
private $username
 

Name of a bot

  • var string|null
private $useShortAttachment
 

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

  • var bool
Methods
private generateAttachmentField(string $title, $value) : array
 

Generates attachment field

    private generateAttachmentFields(array $data) : array
     

    Generates a collection of attachment fields from array

    private removeExcludedFields(array $record) : array
     

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

    © 2020 Bruce Wells
    Search Namespaces \ Classes
    ConfigurationNumbers (0-9.) only