Documentation

NewRelicHandler extends AbstractProcessingHandler
in package

Class to record a log on a NewRelic application.

Enabling New Relic High Security mode may prevent capture of useful information.

This handler requires a NormalizerFormatter to function and expects an array in $record->formatted

Tags
see
https://docs.newrelic.com/docs/agents/php-agent
see
https://docs.newrelic.com/docs/accounts-partnerships/accounts/security/high-security

Table of Contents

Properties

$appName  : string|null
Name of the New Relic application that will receive logs from this handler.
$bubble  : bool
$explodeArrays  : bool
Some context and extra data is passed into the handler as arrays of values. Do we send them as is (useful if we are using the API), or explode them for display on the NewRelic RPM website?
$formatter  : FormatterInterface|null
$level  : Level
$processors  : array<string|int, callable>
$transactionName  : string|null
Name of the current transaction

Methods

__construct()  : mixed
__destruct()  : mixed
__sleep()  : mixed
close()  : void
Closes the handler.
getBubble()  : bool
Gets the bubbling behavior.
getFormatter()  : FormatterInterface
getLevel()  : Level
Gets minimum logging level at which this handler will be triggered.
handle()  : bool
Handles a record.
handleBatch()  : void
Handles a set of records at once.
isHandling()  : bool
Checks whether the given record will be handled by this handler.
popProcessor()  : callable
pushProcessor()  : HandlerInterface
reset()  : void
setBubble()  : $this
Sets the bubbling behavior.
setFormatter()  : HandlerInterface
setLevel()  : $this
Sets minimum logging level at which this handler will be triggered.
getAppName()  : string|null
Returns the appname where this log should be sent. Each log can override the default appname, set in this handler's constructor, by providing the appname in it's context.
getDefaultFormatter()  : FormatterInterface
getTransactionName()  : string|null
Returns the name of the current transaction. Each log can override the default transaction name, set in this handler's constructor, by providing the transaction_name in it's context
isNewRelicEnabled()  : bool
Checks whether the NewRelic extension is enabled in the system.
processRecord()  : LogRecord
resetProcessors()  : void
setNewRelicAppName()  : void
Sets the NewRelic application that should receive this log.
setNewRelicParameter()  : void
setNewRelicTransactionName()  : void
Overwrites the name of the current transaction
write()  : void
Writes the (already formatted) record down to the log of the implementing handler

Properties

$appName

Name of the New Relic application that will receive logs from this handler.

protected string|null $appName = null

$explodeArrays

Some context and extra data is passed into the handler as arrays of values. Do we send them as is (useful if we are using the API), or explode them for display on the NewRelic RPM website?

protected bool $explodeArrays = false

$processors

protected array<string|int, callable> $processors = []
Tags
phpstan-var

array<(callable(LogRecord): LogRecord)|ProcessorInterface>

$transactionName

Name of the current transaction

protected string|null $transactionName = null

Methods

__construct()

public __construct([int|string|Level $level = Level::Error ][, bool $bubble = true ][, string|null $appName = null ][, bool $explodeArrays = false ][, string|null $transactionName = null ]) : mixed
Parameters
$level : int|string|Level = Level::Error

The minimum logging level at which this handler will be triggered

$bubble : bool = true

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

$appName : string|null = null
$explodeArrays : bool = false
$transactionName : string|null = null
Tags
inheritDoc

__destruct()

public __destruct() : mixed

close()

Closes the handler.

public close() : void
Tags
inheritDoc

getBubble()

Gets the bubbling behavior.

public getBubble() : bool
Return values
bool

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

getLevel()

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

public getLevel() : Level
Return values
Level

handle()

Handles a record.

public handle(LogRecord $record) : bool
Parameters
$record : LogRecord

The record to handle

Tags
inheritDoc
Return values
bool

true means that this handler handled the record, and that bubbling is not permitted. false means the record was either not processed or that this handler allows bubbling.

handleBatch()

Handles a set of records at once.

public handleBatch(array<string|int, mixed> $records) : void
Parameters
$records : array<string|int, mixed>

The records to handle

Tags
inheritDoc

isHandling()

Checks whether the given record will be handled by this handler.

public isHandling(LogRecord $record) : bool
Parameters
$record : LogRecord

Partial log record having only a level initialized

Tags
inheritDoc
Return values
bool

setBubble()

Sets the bubbling behavior.

public setBubble(bool $bubble) : $this
Parameters
$bubble : bool

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

Return values
$this

setLevel()

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

public setLevel(Level|LogLevel::* $level) : $this
Parameters
$level : Level|LogLevel::*

Level or level name

Tags
phpstan-param

value-ofLevel::VALUES|value-ofLevel::NAMES|Level|LogLevel::* $level

Return values
$this

getAppName()

Returns the appname where this log should be sent. Each log can override the default appname, set in this handler's constructor, by providing the appname in it's context.

protected getAppName(array<string|int, mixed> $context) : string|null
Parameters
$context : array<string|int, mixed>
Return values
string|null

getTransactionName()

Returns the name of the current transaction. Each log can override the default transaction name, set in this handler's constructor, by providing the transaction_name in it's context

protected getTransactionName(array<string|int, mixed> $context) : string|null
Parameters
$context : array<string|int, mixed>
Return values
string|null

isNewRelicEnabled()

Checks whether the NewRelic extension is enabled in the system.

protected isNewRelicEnabled() : bool
Return values
bool

setNewRelicAppName()

Sets the NewRelic application that should receive this log.

protected setNewRelicAppName(string $appName) : void
Parameters
$appName : string

setNewRelicParameter()

protected setNewRelicParameter(string $key, mixed $value) : void
Parameters
$key : string
$value : mixed

setNewRelicTransactionName()

Overwrites the name of the current transaction

protected setNewRelicTransactionName(string $transactionName) : void
Parameters
$transactionName : string

write()

Writes the (already formatted) record down to the log of the implementing handler

protected write(LogRecord $record) : void
Parameters
$record : LogRecord
Tags
inheritDoc

        
On this page

Search results