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
- Name of the New Relic application that will receive logs from this handler.
- $bubble : mixed
- $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
- $level : mixed
- $processors : mixed
- $transactionName : string
- Name of the current transaction
Methods
- __construct() : mixed
- __destruct() : mixed
- close() : mixed
- Closes the handler.
- getBubble() : bool
- Gets the bubbling behavior.
- getFormatter() : FormatterInterface
- Gets the formatter.
- getLevel() : int
- Gets minimum logging level at which this handler will be triggered.
- handle() : bool
- Handles a record.
- handleBatch() : mixed
- Handles a set of records at once.
- isHandling() : bool
- Checks whether the given record will be handled by this handler.
- popProcessor() : callable
- Removes the processor on top of the stack and returns it.
- pushProcessor() : self
- Adds a processor in the stack.
- reset() : mixed
- setBubble() : self
- Sets the bubbling behavior.
- setFormatter() : self
- Sets the formatter.
- setLevel() : self
- Sets minimum logging level at which this handler will be triggered.
- getAppName() : null|string
- 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
- Gets the default formatter.
- getTransactionName() : null|string
- 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() : array<string|int, mixed>
- Processes a record.
- setNewRelicAppName() : mixed
- Sets the NewRelic application that should receive this log.
- setNewRelicParameter() : mixed
- setNewRelicTransactionName() : mixed
- Overwrites the name of the current transaction
- write() : void
- Writes the 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
$appName
$bubble
protected
mixed
$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
$formatter
protected
FormatterInterface
$formatter
$level
protected
mixed
$level
= \Monolog\Logger::DEBUG
$processors
protected
mixed
$processors
= array()
$transactionName
Name of the current transaction
protected
string
$transactionName
Methods
__construct()
public
__construct([mixed $level = Logger::ERROR ][, mixed $bubble = true ][, string $appName = null ][, bool $explodeArrays = false ][, string $transactionName = null ]) : mixed
Parameters
- $level : mixed = Logger::ERROR
-
The minimum logging level at which this handler will be triggered
- $bubble : mixed = true
-
Whether the messages that are handled can bubble up the stack or not
- $appName : string = null
- $explodeArrays : bool = false
- $transactionName : string = null
__destruct()
public
__destruct() : mixed
close()
Closes the handler.
public
close() : mixed
This will be called automatically when the object is destroyed
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()
Gets the formatter.
public
getFormatter() : FormatterInterface
Return values
FormatterInterfacegetLevel()
Gets minimum logging level at which this handler will be triggered.
public
getLevel() : int
Return values
inthandle()
Handles a record.
public
handle(array<string|int, mixed> $record) : bool
Parameters
- $record : array<string|int, mixed>
-
The record to handle
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) : mixed
Parameters
- $records : array<string|int, mixed>
-
The records to handle (an array of record arrays)
isHandling()
Checks whether the given record will be handled by this handler.
public
isHandling(array<string|int, mixed> $record) : bool
Parameters
- $record : array<string|int, mixed>
-
Partial log record containing only a level key
Return values
boolpopProcessor()
Removes the processor on top of the stack and returns it.
public
popProcessor() : callable
Return values
callablepushProcessor()
Adds a processor in the stack.
public
pushProcessor(mixed $callback) : self
Parameters
- $callback : mixed
Return values
selfreset()
public
reset() : mixed
setBubble()
Sets the bubbling behavior.
public
setBubble(bool $bubble) : self
Parameters
- $bubble : bool
-
true means that this handler allows bubbling. false means that bubbling is not permitted.
Return values
selfsetFormatter()
Sets the formatter.
public
setFormatter(FormatterInterface $formatter) : self
Parameters
- $formatter : FormatterInterface
Return values
selfsetLevel()
Sets minimum logging level at which this handler will be triggered.
public
setLevel(int|string $level) : self
Parameters
- $level : int|string
-
Level or level name
Return values
selfgetAppName()
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) : null|string
Parameters
- $context : array<string|int, mixed>
Return values
null|stringgetDefaultFormatter()
Gets the default formatter.
protected
getDefaultFormatter() : FormatterInterface
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) : null|string
Parameters
- $context : array<string|int, mixed>
Return values
null|stringisNewRelicEnabled()
Checks whether the NewRelic extension is enabled in the system.
protected
isNewRelicEnabled() : bool
Return values
boolprocessRecord()
Processes a record.
protected
processRecord(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
- $record : array<string|int, mixed>
Return values
array<string|int, mixed>setNewRelicAppName()
Sets the NewRelic application that should receive this log.
protected
setNewRelicAppName(string $appName) : mixed
Parameters
- $appName : string
setNewRelicParameter()
protected
setNewRelicParameter(string $key, mixed $value) : mixed
Parameters
- $key : string
- $value : mixed
setNewRelicTransactionName()
Overwrites the name of the current transaction
protected
setNewRelicTransactionName(string $transactionName) : mixed
Parameters
- $transactionName : string
write()
Writes the record down to the log of the implementing handler
protected
write(array<string|int, mixed> $record) : void
Parameters
- $record : array<string|int, mixed>