class SentryHandler extends AbstractProcessingHandler

Properties

protected string|null $environment

The current application environment.

protected string|null $release

The current version of the calling software.

protected FormatterInterface|null $batchFormatter

The formatter to use for the logs generated via handleBatch().

Methods

__construct(HubInterface $hub, int|string|Level $level = Level::Debug, bool $bubble = true, bool $reportExceptions = true, bool $useFormattedMessage = false)

Create a new Sentry handler instance.

void
handleBatch(array $records)

Handle a set of records at once, sending the most severe with the full batch as context.

setBatchFormatter(FormatterInterface $formatter)

Set the formatter for the logs generated by handleBatch().

FormatterInterface
getBatchFormatter()

Get the formatter for the logs generated by handleBatch().

Severity
getLogLevel(Level $logLevel)

Translate Monolog log levels to Sentry Severity.

void
write(LogRecord $record)

Write a log record.

void
doWrite(LogRecord $record)

Write a record to Sentry.

FormatterInterface
getDefaultFormatter()

Get the default formatter.

FormatterInterface
getDefaultBatchFormatter()

Get the default formatter for the logs generated by handleBatch().

setRelease(string $value)

Set the release.

setEnvironment(string $value)

Set the current application environment.

addBreadcrumb(Breadcrumb $crumb)

Add a breadcrumb.

Details

at line 46
__construct(HubInterface $hub, int|string|Level $level = Level::Debug, bool $bubble = true, bool $reportExceptions = true, bool $useFormattedMessage = false)

Create a new Sentry handler instance.

Parameters

HubInterface $hub
int|string|Level $level

The minimum logging level at which this handler will be triggered

bool $bubble

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

bool $reportExceptions

If false, records with an exception in context will be ignored

bool $useFormattedMessage

If true, use the formatted message instead of the raw message

at line 59
void handleBatch(array $records)

Handle a set of records at once, sending the most severe with the full batch as context.

Parameters

array $records

Return Value

void

at line 94
SentryHandler setBatchFormatter(FormatterInterface $formatter)

Set the formatter for the logs generated by handleBatch().

Parameters

FormatterInterface $formatter

Return Value

SentryHandler

at line 104
FormatterInterface getBatchFormatter()

Get the formatter for the logs generated by handleBatch().

Return Value

FormatterInterface

at line 116
protected Severity getLogLevel(Level $logLevel)

Translate Monolog log levels to Sentry Severity.

Parameters

Level $logLevel

Return Value

Severity

at line 130
protected void write(LogRecord $record)

Write a log record.

Parameters

LogRecord $record

Return Value

void

at line 138
protected void doWrite(LogRecord $record)

Write a record to Sentry.

Parameters

LogRecord $record

Return Value

void

at line 207
protected FormatterInterface getDefaultFormatter()

Get the default formatter.

Return Value

FormatterInterface

at line 215
protected FormatterInterface getDefaultBatchFormatter()

Get the default formatter for the logs generated by handleBatch().

Return Value

FormatterInterface

at line 226
SentryHandler setRelease(string $value)

Set the release.

On a cached log channel's handler, per-request use races across coroutines and affects every subsequent log event.

Parameters

string $value

Return Value

SentryHandler

at line 240
SentryHandler setEnvironment(string $value)

Set the current application environment.

On a cached log channel's handler, per-request use races across coroutines and affects every subsequent log event.

Parameters

string $value

Return Value

SentryHandler

at line 253
SentryHandler addBreadcrumb(Breadcrumb $crumb)

Add a breadcrumb.

Parameters

Breadcrumb $crumb

Return Value

SentryHandler