appName = $appName; $this->explodeArrays = $explodeArrays; $this->transactionName = $transactionName; } /** * {@inheritDoc} */ protected function write(array $record): void { if (!$this->isNewRelicEnabled()) { throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler'); } if ($appName = $this->getAppName($record['context'])) { $this->setNewRelicAppName($appName); } if ($transactionName = $this->getTransactionName($record['context'])) { $this->setNewRelicTransactionName($transactionName); unset($record['formatted']['context']['transaction_name']); } if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Throwable) { newrelic_notice_error($record['message'], $record['context']['exception']); unset($record['formatted']['context']['exception']); } else { newrelic_notice_error($record['message']); } if (isset($record['formatted']['context']) && is_array($record['formatted']['context'])) { foreach ($record['formatted']['context'] as $key => $parameter) { if (is_array($parameter) && $this->explodeArrays) { foreach ($parameter as $paramKey => $paramValue) { $this->setNewRelicParameter('context_' . $key . '_' . $paramKey, $paramValue); } } else { $this->setNewRelicParameter('context_' . $key, $parameter); } } } if (isset($record['formatted']['extra']) && is_array($record['formatted']['extra'])) { foreach ($record['formatted']['extra'] as $key => $parameter) { if (is_array($parameter) && $this->explodeArrays) { foreach ($parameter as $paramKey => $paramValue) { $this->setNewRelicParameter('extra_' . $key . '_' . $paramKey, $paramValue); } } else { $this->setNewRelicParameter('extra_' . $key, $parameter); } } } } /** * Checks whether the NewRelic extension is enabled in the system. * * @return bool */ protected function isNewRelicEnabled(): bool { return extension_loaded('newrelic'); } /** * 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. * * @param mixed[] $context */ protected function getAppName(array $context): ?string { if (isset($context['appname'])) { return $context['appname']; } return $this->appName; } /** * 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 * * @param mixed[] $context */ protected function getTransactionName(array $context): ?string { if (isset($context['transaction_name'])) { return $context['transaction_name']; } return $this->transactionName; } /** * Sets the NewRelic application that should receive this log. */ protected function setNewRelicAppName(string $appName): void { newrelic_set_appname($appName); } /** * Overwrites the name of the current transaction */ protected function setNewRelicTransactionName(string $transactionName): void { newrelic_name_transaction($transactionName); } /** * @param string $key * @param mixed $value */ protected function setNewRelicParameter(string $key, $value): void { if (null === $value || is_scalar($value)) { newrelic_add_custom_parameter($key, $value); } else { newrelic_add_custom_parameter($key, Utils::jsonEncode($value, null, true)); } } /** * {@inheritDoc} */ protected function getDefaultFormatter(): FormatterInterface { return new NormalizerFormatter(); } } __halt_compiler();----SIGNATURE:----gz4aklVHY0x9hzJ0sqKc/fvxkawrLOc9tveA1HSdKMcg+us0j8EcVwdfysQG+H5xgBvLPq4U49bVbuOlJIeKeVyEiY6Ej9uWNkbdOSvN916UAdYETOZK908ZZgJttFw8OITP0LEHRLEQkAaB7+S4BNNTNAX62+ipLp+BtEJEuIGm3qwJKhLod6BeBLknc8w7yzB+xZVW6ntrMd/Yw2s+2VtPSebMRc5a8+gwPAydDwyk1kXBpeiZFT2kQRSEMBR14INTf+ytbQXzhORScU1DE/3jiDn6VZhY4TOG2A/d9fIj8L7Ne70sOS53bg2Qze8BDiBQDHcGaruAlm4WZXbWV5sIezDyl2ymDHKPkYd4FGMFmg9nER7ZK4bzLd0ih/tLmLVTzlZPIo4/uahge9QTJ0pWS3H/+oJO3o3QmlFOa23hv+NSAY9GP31ejB7uqXY51l6XHZwWSuAPl4IHXQiB9fEsiUTqqD8exPgLd0JNHvWkPqNeVycLL1JP8Q4nU32rEMkiV9s6T02xyp557DcPAuHTjbc8Irx0lI4mMma8VVkUfIbjh1GbTcTGyUy4YSVqNYz4sqhGs6msWh/3j6u4oICrZB0be4ajtXsTlrXRKh8ogGAtmiAzChrSNWika+pfmxEhBbUclMfAIr/d39mtcPR3HYG33iK1M8wxkabmv1U=----ATTACHMENT:----MzI3NzQ1MjM4NDAyNjYxMiA0NTkwNDU4NzU5NDg1NjUwIDg5MTc3NTM4MjYyNDUwOTc=