fjffk简�的咖啡店科开�2方法2
环æ»�皆山也。其西å�—诸峰,林壑尤美,望之蔚然而深秀者,ç�…ç�Šä¹Ÿã€‚山行å…七里,æ¸�闻水声潺潺,而泻出于两峰之间者,酿泉也
???????????????????????????????
??????????????/?????????????????
............/...................
.........................../...
???????????????????????????????
>>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>
ÿØÿà JFIF ÿÛ „ ( %!1!%)+//.383,7(-.+
-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ ¥2" ÿÄ ÿÄ J ! 1AQ"aq�2‘#BR‚¡�Ñ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ ÿÄ * !1AQa‘"2q3�±ð#b¡ÿÚ ? ¼QxJQa�uò¸Zö Úü8,�Úú
"SSn<rçù–´âE—^ªBÖ9À\†¸Â�ÔÂ�Ã�TÂÃÛ5
ëd´³Ã�#Ã�;Þ38ϔÂ� ¶H£M:wÃŽ3…³…âpÔF&‚FK¸9„â4à GEõªfÂ�ÿ ‘ñ(ßwÂpŽF|È¥ù®häðÃ�Ѷ¹‘[Ã’inÙW¶ùñYËœQ{›K"išÒ[Ú8žë\F¹@-?v"ÔUâ€�,ìöžkÿ {I‡£šÃ�?e
rÂ�ÃV
?>
.........................................
.............................................................................
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
dsdfPK \sW]§J£zD D LICENSEnu „[µü¤ MIT License
Copyright (c) 2016 Functional Software, Inc. dba Sentry
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.PK \sW]7öØ README.mdnu „[µü¤
_Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us [**Check out our open positions**](https://sentry.io/careers/)_
# Official Sentry SDK for Laravel
[](https://github.com/getsentry/sentry-laravel/actions/workflows/ci.yaml)
[](https://packagist.org/packages/sentry/sentry-laravel)
[](https://packagist.org/packages/sentry/sentry-laravel)
[](https://packagist.org/packages/sentry/sentry-laravel)
[](https://packagist.org/packages/sentry/sentry-laravel)
[](https://discord.gg/cWnMQeA)
This is the official Laravel SDK for [Sentry](https://sentry.io).
## Getting Started
The installation steps below work on versions 12.x and 11.x of the Laravel framework.
For older Laravel versions and Lumen see:
- [Laravel 12.x & 11.x](https://docs.sentry.io/platforms/php/guides/laravel/)
- [Laravel 10.x & 9.x & 8.x](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/laravel8-10/)
- [Laravel 7.x & 6.x](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/laravel6-7/)
- [Laravel 5.x](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/laravel5/)
- [Laravel 4.x](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/laravel4/)
- [Lumen](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen/)
### Install
Install the `sentry/sentry-laravel` package:
```bash
composer require sentry/sentry-laravel
```
Enable capturing unhandled exception to report to Sentry by making the following change to your `bootstrap/app.php`:
```php {filename:bootstrap/app.php}
withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
Integration::handles($exceptions);
})->create();
```
> Alternatively, you can configure Sentry as a [Laravel Log Channel](https://docs.sentry.io/platforms/php/guides/laravel/usage/#log-channels), allowing you to capture `info` and `debug` logs as well.
### Configure
Configure the Sentry DSN with this command:
```shell
php artisan sentry:publish --dsn=___PUBLIC_DSN___
```
It creates the config file (`config/sentry.php`) and adds the `DSN` to your `.env` file.
```shell {filename:.env}
SENTRY_LARAVEL_DSN=___PUBLIC_DSN___
```
### Usage
```php
use function Sentry\captureException;
try {
$this->functionThatMayFail();
} catch (\Throwable $exception) {
captureException($exception);
}
```
To learn more about how to use the SDK [refer to our docs](https://docs.sentry.io/platforms/php/guides/laravel/).
## Laravel Version Compatibility
The Laravel and Lumen versions listed below are all currently supported:
- Laravel `>= 11.x.x` on PHP `>= 8.2` is supported starting from `4.3.0`
- Laravel `>= 10.x.x` on PHP `>= 8.1` is supported starting from `3.2.0`
- Laravel `>= 9.x.x` on PHP `>= 8.0` is supported starting from `2.11.0`
- Laravel `>= 8.x.x` on PHP `>= 7.3` is supported starting from `1.9.0`
- Laravel `>= 7.x.x` on PHP `>= 7.2` is supported starting from `1.7.0`
- Laravel `>= 6.x.x` on PHP `>= 7.2` is supported starting from `1.2.0`
Please note that starting with version `>= 2.0.0` we require PHP Version `>= 7.2` because we are using our new [PHP SDK](https://github.com/getsentry/sentry-php) underneath.
The Laravel versions listed below were supported in previous versions of the Sentry SDK for Laravel:
- Laravel `<= 4.2.x` is supported until `0.8.x`
- Laravel `<= 5.7.x` on PHP `<= 7.0` is supported until `0.11.x`
- Laravel `>= 5.x.x` on PHP `>= 7.1` is supported until `2.14.x`
## Contributing to the SDK
Please refer to [CONTRIBUTING.md](CONTRIBUTING.md).
### Thanks to all the people who contributed so far!
## Getting Help/Support
If you need help setting up or configuring the Laravel SDK (or anything else in the Sentry universe) please head over to the [Sentry Community on Discord](https://discord.com/invite/Ww9hbqr). There is a ton of great people in our Discord community ready to help you!
## Resources
- [](https://docs.sentry.io/quickstart/)
- [](https://discord.gg/Ww9hbqr)
- [](http://stackoverflow.com/questions/tagged/sentry)
- [](https://twitter.com/intent/follow?screen_name=getsentry)
## License
Licensed under the MIT license, see [`LICENSE`](LICENSE).
PK \sW]�c¥ .php-cs-fixer.phpnu „[µü¤ in(__DIR__ . '/src')
;
$config = new PhpCsFixer\Config;
$config
->setRules([
'@PSR2' => true,
'nullable_type_declaration_for_default_null_value' => true,
])
->setFinder($finder)
;
return $config;
PK \sW] ½AY Y phpstan.neonnu „[µü¤ includes:
- phpstan-baseline.neon
parameters:
level: 1
paths:
- src
PK \sW]ö¹*Ä) ) phpstan-baseline.neonnu „[µü¤ parameters:
ignoreErrors:
-
message: "#^Class Laravel\\\\Octane\\\\Events\\\\RequestReceived not found\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Class Laravel\\\\Octane\\\\Events\\\\RequestTerminated not found\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Class Laravel\\\\Octane\\\\Events\\\\TaskReceived not found\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Class Laravel\\\\Octane\\\\Events\\\\TaskTerminated not found\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Class Laravel\\\\Octane\\\\Events\\\\TickReceived not found\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Class Laravel\\\\Octane\\\\Events\\\\TickTerminated not found\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Class Laravel\\\\Octane\\\\Events\\\\WorkerErrorOccurred not found\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Class Laravel\\\\Octane\\\\Events\\\\WorkerStopping not found\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Class Laravel\\\\Sanctum\\\\Events\\\\TokenAuthenticated not found\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\EventHandler\\:\\:octaneRequestReceivedHandler\\(\\) has invalid type Laravel\\\\Octane\\\\Events\\\\RequestReceived\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\EventHandler\\:\\:octaneRequestTerminatedHandler\\(\\) has invalid type Laravel\\\\Octane\\\\Events\\\\RequestTerminated\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\EventHandler\\:\\:octaneTaskReceivedHandler\\(\\) has invalid type Laravel\\\\Octane\\\\Events\\\\TaskReceived\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\EventHandler\\:\\:octaneTaskTerminatedHandler\\(\\) has invalid type Laravel\\\\Octane\\\\Events\\\\TaskTerminated\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\EventHandler\\:\\:octaneTickReceivedHandler\\(\\) has invalid type Laravel\\\\Octane\\\\Events\\\\TickReceived\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\EventHandler\\:\\:octaneTickTerminatedHandler\\(\\) has invalid type Laravel\\\\Octane\\\\Events\\\\TickTerminated\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\EventHandler\\:\\:octaneWorkerErrorOccurredHandler\\(\\) has invalid type Laravel\\\\Octane\\\\Events\\\\WorkerErrorOccurred\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\EventHandler\\:\\:octaneWorkerStoppingHandler\\(\\) has invalid type Laravel\\\\Octane\\\\Events\\\\WorkerStopping\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Parameter \\$event of method Sentry\\\\Laravel\\\\EventHandler\\:\\:sanctumTokenAuthenticatedHandler\\(\\) has invalid type Laravel\\\\Sanctum\\\\Events\\\\TokenAuthenticated\\.$#"
count: 1
path: src/Sentry/Laravel/EventHandler.php
-
message: "#^Parameter \\$request of method Sentry\\\\Laravel\\\\Features\\\\LivewirePackageIntegration\\:\\:handleComponentBooted\\(\\) has invalid type Livewire\\\\Request\\.$#"
count: 1
path: src/Sentry/Laravel/Features/LivewirePackageIntegration.php
-
message: "#^Call to protected method resolve\\(\\) of class Illuminate\\\\Filesystem\\\\FilesystemManager\\.$#"
count: 1
path: src/Sentry/Laravel/Features/Storage/Integration.php
-
message: "#^Class Laravel\\\\Lumen\\\\Application not found\\.$#"
count: 3
path: src/Sentry/Laravel/ServiceProvider.php
-
message: "#^Class GraphQL\\\\Language\\\\AST\\\\DocumentNode not found\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Class GraphQL\\\\Language\\\\AST\\\\OperationDefinitionNode not found\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Class Nuwave\\\\Lighthouse\\\\Events\\\\EndExecution not found\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Class Nuwave\\\\Lighthouse\\\\Events\\\\EndRequest not found\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Class Nuwave\\\\Lighthouse\\\\Events\\\\StartExecution not found\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Class Nuwave\\\\Lighthouse\\\\Events\\\\StartRequest not found\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Method Sentry\\\\Laravel\\\\Tracing\\\\Integrations\\\\LighthouseIntegration\\:\\:extractOperationDefinitionNode\\(\\) has invalid return type GraphQL\\\\Language\\\\AST\\\\OperationDefinitionNode\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Parameter \\$endExecution of method Sentry\\\\Laravel\\\\Tracing\\\\Integrations\\\\LighthouseIntegration\\:\\:handleEndExecution\\(\\) has invalid type Nuwave\\\\Lighthouse\\\\Events\\\\EndExecution\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Parameter \\$endRequest of method Sentry\\\\Laravel\\\\Tracing\\\\Integrations\\\\LighthouseIntegration\\:\\:handleEndRequest\\(\\) has invalid type Nuwave\\\\Lighthouse\\\\Events\\\\EndRequest\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Parameter \\$operation of method Sentry\\\\Laravel\\\\Tracing\\\\Integrations\\\\LighthouseIntegration\\:\\:extractOperationNames\\(\\) has invalid type GraphQL\\\\Language\\\\AST\\\\OperationDefinitionNode\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Parameter \\$query of method Sentry\\\\Laravel\\\\Tracing\\\\Integrations\\\\LighthouseIntegration\\:\\:extractOperationDefinitionNode\\(\\) has invalid type GraphQL\\\\Language\\\\AST\\\\DocumentNode\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Parameter \\$startExecution of method Sentry\\\\Laravel\\\\Tracing\\\\Integrations\\\\LighthouseIntegration\\:\\:handleStartExecution\\(\\) has invalid type Nuwave\\\\Lighthouse\\\\Events\\\\StartExecution\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Parameter \\$startRequest of method Sentry\\\\Laravel\\\\Tracing\\\\Integrations\\\\LighthouseIntegration\\:\\:handleStartRequest\\(\\) has invalid type Nuwave\\\\Lighthouse\\\\Events\\\\StartRequest\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
-
message: "#^Class Laravel\\\\Lumen\\\\Application not found\\.$#"
count: 1
path: src/Sentry/Laravel/Tracing/Middleware.php
-
message: "#^Class Laravel\\\\Lumen\\\\Application not found\\.$#"
count: 2
path: src/Sentry/Laravel/Tracing/ServiceProvider.php
PK \sW]Fÿ}4› › src/Sentry/Laravel/Version.phpnu „[µü¤ hub = $hub;
$this->reportExceptions = $reportExceptions;
$this->useFormattedMessage = $useFormattedMessage;
}
/**
* {@inheritdoc}
*/
public function handleBatch(array $records): void
{
$level = $this->level;
// filter records based on their level
$records = array_filter(
$records,
function ($record) use ($level) {
return $record['level'] >= $level;
}
);
if (!$records) {
return;
}
// the record with the highest severity is the "main" one
$record = array_reduce(
$records,
function ($highest, $record) {
if ($highest === null || $record['level'] > $highest['level']) {
return $record;
}
return $highest;
}
);
// the other ones are added as a context item
$logs = [];
foreach ($records as $r) {
$logs[] = $this->processRecord($r);
}
if ($logs) {
$record['context']['logs'] = (string)$this->getBatchFormatter()->formatBatch($logs);
}
$this->handle($record);
}
/**
* Sets the formatter for the logs generated by handleBatch().
*
* @param FormatterInterface $formatter
*
* @return \Sentry\Laravel\SentryHandler
*/
public function setBatchFormatter(FormatterInterface $formatter): self
{
$this->batchFormatter = $formatter;
return $this;
}
/**
* Gets the formatter for the logs generated by handleBatch().
*/
public function getBatchFormatter(): FormatterInterface
{
if (!$this->batchFormatter) {
$this->batchFormatter = $this->getDefaultBatchFormatter();
}
return $this->batchFormatter;
}
/**
* Translates Monolog log levels to Sentry Severity.
*
* @param int $logLevel
*
* @return \Sentry\Severity
*/
protected function getLogLevel(int $logLevel): Severity
{
return $this->getSeverityFromLevel($logLevel);
}
/**
* {@inheritdoc}
* @suppress PhanTypeMismatchArgument
*/
protected function doWrite($record): void
{
$exception = $record['context']['exception'] ?? null;
$isException = $exception instanceof Throwable;
unset($record['context']['exception']);
if (!$this->reportExceptions && $isException) {
return;
}
$this->hub->withScope(
function (Scope $scope) use ($record, $isException, $exception) {
$context = !empty($record['context']) && is_array($record['context'])
? $record['context']
: [];
if (!empty($context)) {
$this->consumeContextAndApplyToScope($scope, $context);
}
if (!empty($record['extra']) && is_array($record['extra'])) {
foreach ($record['extra'] as $key => $extra) {
$scope->setExtra($key, $extra);
}
}
$logger = !empty($context['logger']) && is_string($context['logger'])
? $context['logger']
: null;
unset($context['logger']);
// At this point we consumed everything we could from the context
// what remains we add as `log_context` to the event as a whole
if (!empty($context)) {
$scope->setExtra('log_context', $context);
}
$scope->addEventProcessor(
function (Event $event) use ($record, $logger) {
$event->setLevel($this->getLogLevel($record['level']));
$event->setLogger($logger ?? $record['channel']);
if (!empty($this->environment) && !$event->getEnvironment()) {
$event->setEnvironment($this->environment);
}
if (!empty($this->release) && !$event->getRelease()) {
$event->setRelease($this->release);
}
if (isset($record['datetime']) && $record['datetime'] instanceof DateTimeInterface) {
$event->setTimestamp($record['datetime']->getTimestamp());
}
return $event;
}
);
if ($isException) {
$this->hub->captureException($exception);
} else {
$this->hub->captureMessage(
$this->useFormattedMessage || empty($record['message'])
? $record['formatted']
: $record['message']
);
}
}
);
}
/**
* {@inheritDoc}
*/
protected function getDefaultFormatter(): FormatterInterface
{
return new LineFormatter('[%channel%] %message%');
}
/**
* Gets the default formatter for the logs generated by handleBatch().
*
* @return FormatterInterface
*/
protected function getDefaultBatchFormatter(): FormatterInterface
{
return new LineFormatter();
}
/**
* Set the release.
*
* @param string $value
*
* @return self
*/
public function setRelease($value): self
{
$this->release = $value;
return $this;
}
/**
* Set the current application environment.
*
* @param string $value
*
* @return self
*/
public function setEnvironment($value): self
{
$this->environment = $value;
return $this;
}
/**
* Add a breadcrumb.
*
* @link https://docs.sentry.io/learn/breadcrumbs/
*
* @param \Sentry\Breadcrumb $crumb
*
* @return \Sentry\Laravel\SentryHandler
*/
public function addBreadcrumb(Breadcrumb $crumb): self
{
$this->hub->addBreadcrumb($crumb);
return $this;
}
/**
* Consumes the context and applies it to the scope.
*
* @param \Sentry\State\Scope $scope
* @param array $context
*
* @return void
*/
private function consumeContextAndApplyToScope(Scope $scope, array &$context): void
{
if (!empty($context['extra']) && is_array($context['extra'])) {
foreach ($context['extra'] as $key => $value) {
$scope->setExtra($key, $value);
}
unset($context['extra']);
}
if (!empty($context['tags']) && is_array($context['tags'])) {
foreach ($context['tags'] as $tag => $value) {
// Ignore tags with a value that is not a string or can be casted to a string
if (!$this->valueCanBeString($value)) {
continue;
}
$scope->setTag($tag, (string)$value);
}
unset($context['tags']);
}
if (!empty($context['fingerprint']) && is_array($context['fingerprint'])) {
$scope->setFingerprint($context['fingerprint']);
unset($context['fingerprint']);
}
if (!empty($context['user']) && is_array($context['user'])) {
try {
$scope->setUser($context['user']);
unset($context['user']);
} catch (TypeError $e) {
// In some cases the context can be invalid, in that case we ignore it and
// choose to not send it to Sentry in favor of not breaking the application
}
}
}
/**
* Check if the value passed can be cast to a string.
*
* @param mixed $value
*
* @return bool
*/
private function valueCanBeString($value): bool
{
return is_string($value) || is_scalar($value) || (is_object($value) && method_exists($value, '__toString'));
}
}
PK \sW]±û- - ' src/Sentry/Laravel/Logs/LogsHandler.phpnu „[µü¤ level;
// filter records based on their level
$records = array_filter(
$records,
function ($record) use ($level) {
return $record['level'] >= $level;
}
);
if (!$records) {
return;
}
// the record with the highest severity is the "main" one
$record = array_reduce(
$records,
function ($highest, $record) {
if ($highest === null || $record['level'] > $highest['level']) {
return $record;
}
return $highest;
}
);
// the other ones are added as a context item
$logs = [];
foreach ($records as $r) {
$logs[] = $this->processRecord($r);
}
if ($logs) {
$record['context']['logs'] = (string)$this->getBatchFormatter()->formatBatch($logs);
}
$this->handle($record);
}
/**
* Sets the formatter for the logs generated by handleBatch().
*
* @param FormatterInterface $formatter
*
* @return \Sentry\Laravel\SentryHandler
*/
public function setBatchFormatter(FormatterInterface $formatter): self
{
$this->batchFormatter = $formatter;
return $this;
}
/**
* Gets the formatter for the logs generated by handleBatch().
*/
public function getBatchFormatter(): FormatterInterface
{
if (!$this->batchFormatter) {
$this->batchFormatter = new LineFormatter();
}
return $this->batchFormatter;
}
/**
* {@inheritdoc}
* @suppress PhanTypeMismatchArgument
*/
protected function doWrite($record): void
{
$context = $record['context'];
$exception = $context['exception'] ?? null;
if ($exception instanceof Throwable) {
// Unset the exception object from the log context
unset($context['exception']);
}
logger()->aggregator()->add(
// This seems a little bit of a roundabout way to get the log level, but this is done for compatibility
self::getLogLevelFromSeverity(
self::getSeverityFromLevel($record['level'])
),
$record['message'],
[],
array_merge($context, $record['extra'], ['sentry.origin' => 'auto.logger.monolog'])
);
}
private static function getLogLevelFromSeverity(Severity $severity): LogLevel
{
switch ($severity) {
case Severity::debug():
return LogLevel::debug();
case Severity::warning():
return LogLevel::warn();
case Severity::error():
return LogLevel::error();
case Severity::fatal():
return LogLevel::fatal();
default:
return LogLevel::info();
}
}
}
PK \sW]xÈï�
&