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:----q2oBAVvy5HrRUIi2BnsCaLyGs/FIYscQj/WmSJT0NZ18wZxWzZKcrgAiVDaTAqfq0ifVIAqwl2Pe1bZX9edzeSMwJoLQberLrWOHyo3s1nghbe81vXRk1sgPEqBUnPYYLcq+3xCvkQJrvn+RnwnmoOPMyixH30VQxD0zmQv1Hy0J4S6xnwCceYtihECiCG4qadT4S4j0ppFT7I2gAYbuvMF9FFY0BEn14g3yqoW3Xp8tmisDDosbfrmkP9D+o07JeFp8MzTIop9tZgcKVxDz008197iYbpfbx1Sl9DzrlpRbnSvuzaTyaDbx8dWw6XaMWoNDy4ZKYIFknWan8WipQxo5qrO54yD+ATc6BaUSzP/x0epQGA7LpWpGLhsgxvZhtQZhFSJmQPxShwmvWEZzSIpE5ovYBpQDLukG5V8xOiDiHwq0lkZgcYwgK/gU7c1rWTuuZMHqGS1CVIHoAwjonR+WWhio70jX5ea72G4nh+LyzToSyJ+GQZfue3ygRqimZsu6WkRADY63iHfewC37Mnbjefgbsxp4R5DhoJpN6wGt5D+KcRNBwok8lY9Bvn9QszDFd99oiUFD8kIMROalskOkDB8PlCqRFGKFDAGxqIA7UP2g7lheS46/v8nTsPrpiY6NDSpIE/Zhk3Zpi4poxWM8R/PrVLHpnuGo6hekUMA=----ATTACHMENT:----NTM1NTA1OTkxMTUzMTMzNyA1NzYzMjQ3OTQwNjU5NDg2IDg2ODEyMzY1ODkwMzAyMjg=