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
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
$bubble
protected
bool
$bubble
= true
$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
$formatter
protected
FormatterInterface|null
$formatter
= null
$level
protected
Level
$level
= \Monolog\Level::Debug
$processors
protected
array<string|int, callable>
$processors
= []
Tags
$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
__destruct()
public
__destruct() : mixed
__sleep()
public
__sleep() : mixed
close()
Closes the handler.
public
close() : void
Tags
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.
getFormatter()
public
getFormatter() : FormatterInterface
Tags
Return values
FormatterInterfacegetLevel()
Gets minimum logging level at which this handler will be triggered.
public
getLevel() : Level
Return values
Levelhandle()
Handles a record.
public
handle(LogRecord $record) : bool
Parameters
- $record : LogRecord
-
The record to handle
Tags
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
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
Return values
boolpopProcessor()
public
popProcessor() : callable
Tags
Return values
callablepushProcessor()
public
pushProcessor(callable $callback) : HandlerInterface
Parameters
- $callback : callable
Tags
Return values
HandlerInterfacereset()
public
reset() : void
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
$thissetFormatter()
public
setFormatter(FormatterInterface $formatter) : HandlerInterface
Parameters
- $formatter : FormatterInterface
Tags
Return values
HandlerInterfacesetLevel()
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
Return values
$thisgetAppName()
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|nullgetDefaultFormatter()
protected
getDefaultFormatter() : FormatterInterface
Tags
Return values
FormatterInterfacegetTransactionName()
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|nullisNewRelicEnabled()
Checks whether the NewRelic extension is enabled in the system.
protected
isNewRelicEnabled() : bool
Return values
boolprocessRecord()
protected
processRecord(LogRecord $record) : LogRecord
Parameters
- $record : LogRecord
Return values
LogRecordresetProcessors()
protected
resetProcessors() : void
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