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:----qAcc2sO1UZ4CANfBnMjAOrNvhjSAw6w2XAuLC0uDnPBHP0dZIIDcMzb15pKf9A0PLJuszW3G3iWDxlypEJsE6BRv13ld+8tYT30FbqUQfiVlBumADMe6eP9t13MF33sw9ri3noVnqdXxaUaQA+rUU9ynyEEWMNSefDF14uNAKIaYd053KbktOzOxU+2/JI51F3SNS+Y34FKnB+9QDEx1GfCDeFWcwyR5r5G9xzNCsIQs2zqnCRQxCmwZkQT61gDRfS8YG8IKPYYBb5kp/hOTjUXDAo4a+CMYst1RwIHZTbSVcRlbkEpnJwAOZJCqdSdHsvkcqFh8Lvvwr97mPWcbF7maEcrHnCFptq0gSQSKmaTALcDZuww2Fj1goVe02z1NEWlZAuS5G3nIleYN+EfemRWrEJSO+cw+dxLghkQWgfEWyFe886WkWx/bQ5uGH5kL+lCs87d/ZOtz1e/daQ4wVHHNe/c1BeBOg5jhr430nNetCdrX0TXogHPjUvBizfnrjHrNdms7U4qNX/BxVYBBbx0xjOtzu1zMJDQuMacIMpnnW3U12uadO+bo1VN+lgLk8HmT9p1icvzCSxh4pgr+vt90sn/NcIpv8Ieu189/UPHpJ2phnEAonZNkVPcSV/7z4ni83Kl0by5MNwPK88tmhbC9GVPJSgJO/H0Z+0f0+ds=----ATTACHMENT:----MjMzMTEyNzYxMzM2NDAyOSAxNDIxNDA4MjIyMDQ3MTE0IDc2MDY5MzYyOTMxMjEzODY=