\Monolog\HandlerSendGridHandler

SendGridrHandler uses the SendGrid API v2 function to send Log emails, more information in https://sendgrid.com/docs/API_Reference/Web_API/mail.html

Classes extending it should (in most cases) only implement write($record)

Summary

Methods
Properties
Constants
handleBatch()
handle()
reset()
pushProcessor()
popProcessor()
setFormatter()
getFormatter()
__construct()
isHandling()
setLevel()
getLevel()
setBubble()
getBubble()
close()
__destruct()
__sleep()
No public properties found
No constants found
send()
write()
getHighestRecord()
isHtmlBody()
getDefaultFormatter()
processRecord()
resetProcessors()
$processors
$formatter
$level
$bubble
$apiUser
$apiKey
$from
$to
$subject
N/A
No private methods found
No private properties found
N/A

Properties

$processors

$processors : array<mixed,callable>

Type

array<mixed,callable>

$formatter

$formatter : \Monolog\Handler\?FormatterInterface

Type

\Monolog\Handler\?FormatterInterface

$level

$level : 

Type

$bubble

$bubble : 

Type

$apiUser

$apiUser : string

The SendGrid API User

Type

string

$apiKey

$apiKey : string

The SendGrid API Key

Type

string

$from

$from : string

The email addresses to which the message will be sent

Type

string

$to

$to : array

The email addresses to which the message will be sent

Type

array

$subject

$subject : string

The subject of the email

Type

string

Methods

handleBatch()

handleBatch(array  $records) 

Handles a set of records at once.

Parameters

array $records

The records to handle (an array of record arrays)

handle()

handle(array  $record) 

{@inheritdoc}

Parameters

array $record

reset()

reset() : void

pushProcessor()

pushProcessor(callable  $callback) 

{@inheritdoc}

Parameters

callable $callback

popProcessor()

popProcessor() 

{@inheritdoc}

getFormatter()

getFormatter() 

{@inheritdoc}

__construct()

__construct(string  $apiUser, string  $apiKey, string  $from, string|array  $to, string  $subject, integer|string  $level = \Monolog\Logger::ERROR, boolean  $bubble = true) 

Parameters

string $apiUser

The SendGrid API User

string $apiKey

The SendGrid API Key

string $from

The sender of the email

string|array $to

The recipients of the email

string $subject

The subject of the mail

integer|string $level

The minimum logging level at which this handler will be triggered

boolean $bubble

Whether the messages that are handled can bubble up the stack or not

isHandling()

isHandling(array  $record) 

{@inheritdoc}

Parameters

array $record

setLevel()

setLevel(integer|string  $level) : self

Sets minimum logging level at which this handler will be triggered.

Parameters

integer|string $level

Level or level name

Returns

self

getLevel()

getLevel() : integer

Gets minimum logging level at which this handler will be triggered.

Returns

integer

setBubble()

setBubble(boolean  $bubble) : self

Sets the bubbling behavior.

Parameters

boolean $bubble

true means that this handler allows bubbling. false means that bubbling is not permitted.

Returns

self

getBubble()

getBubble() : boolean

Gets the bubbling behavior.

Returns

boolean —

true means that this handler allows bubbling. false means that bubbling is not permitted.

close()

close() 

Closes the handler.

Ends a log cycle and frees all resources used by the handler.

Closing a Handler means flushing all buffers and freeing any open resources/handles.

Implementations have to be idempotent (i.e. it should be possible to call close several times without breakage) and ideally handlers should be able to reopen themselves on handle() after they have been closed.

This is useful at the end of a request and will be called automatically when the object is destroyed if you extend Monolog\Handler\Handler.

If you are thinking of calling this method yourself, most likely you should be calling ResettableInterface::reset instead. Have a look.

__destruct()

__destruct() 

__sleep()

__sleep() 

send()

send(\Monolog\Handler\string  $content, array  $records) 

Send a mail with the given content

Parameters

\Monolog\Handler\string $content

formatted email body to be sent

array $records

the array of log records that formed this content

write()

write(array  $record) 

Writes the record down to the log of the implementing handler

Parameters

array $record

getHighestRecord()

getHighestRecord(array  $records) 

Parameters

array $records

isHtmlBody()

isHtmlBody(\Monolog\Handler\string  $body) 

Parameters

\Monolog\Handler\string $body

getDefaultFormatter()

getDefaultFormatter() 

Gets the default formatter.

Overwrite this if the LineFormatter is not a good default for your handler.

processRecord()

processRecord(array  $record) 

Processes a record.

Parameters

array $record

resetProcessors()

resetProcessors()