You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-2Lines changed: 12 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,8 @@ It is a [Monolog](https://github.com/Seldaek/monolog) handler for Sentry PHP SDK
11
11
- Send each log record to a [Sentry](https://sentry.io) server
12
12
- Send log records as breadcrumbs when they are handled in batch; the main reported log record is the one with the highest log level
13
13
- Send log along with exception when one is set in the main log record context
14
-
- Workaround for [an issue](https://github.com/getsentry/sentry-php/issues/811) that prevents sending logs in long running process
14
+
- Compatible with Monolog 1 and 2
15
+
-~~Workaround for [an issue](https://github.com/getsentry/sentry-php/issues/811) that prevents sending logs in long running process~~
15
16
16
17
## Requirements
17
18
@@ -46,6 +47,15 @@ $logger->error('Bar');
46
47
47
48
Check out the [handler constructor](src/SentryHandler.php) to know how to control the minimum logging level and bubbling.
48
49
50
+
>:information_source:
51
+
>
52
+
>- It is a good idea to combine this handler with a `FingersCrossedHandler` and a `BufferHandler`
53
+
>to leverage Sentry breadcrumbs. It gives maximum context for each Sentry event and prevents slowing down http requests.
54
+
>- Beware of issue [getsentry/sentry-php#878](https://github.com/getsentry/sentry-php/issues/878) that can be solved by
55
+
>using another HTTP client
56
+
>
57
+
>Check out the symfony guide for a complete example that address all these points
58
+
49
59
## Documentation
50
60
51
61
-[Symfony guide](doc/guide-symfony.md): it gives a way to integrate this handler to your app
@@ -57,7 +67,7 @@ Check out the [handler constructor](src/SentryHandler.php) to know how to contro
57
67
It is pretty much the same thing but this one captures Monolog records as breadcrumbs
58
68
when flushing in batch.
59
69
60
-
It provides a workaround for [issue 811](https://github.com/getsentry/sentry-php/issues/811) which prevents sending events to Sentry in long running process.
70
+
~~It provides a workaround for [issue getsentry/sentry-php#811](https://github.com/getsentry/sentry-php/issues/811) which prevents sending events to Sentry in long running process.~~
61
71
62
72
Breadcrumbs support has been proposed in a pull request that has been refused for good reasons that
63
73
can be checked in the [PR](https://github.com/getsentry/sentry-php/pull/844). Basically the official one aims to be as simple as possible.
// DO NOT use the http client from Symfony or you could turn into an infinite loop depending on your monolog config and the if logging of HTTP request is enabled or not
129
+
$client = HttpClient::create(['timeout' => 2]);
130
+
131
+
$this->client = new Psr18Client($client, $factory, $factory);
132
+
}
133
+
134
+
/**
135
+
* {@inheritdoc}
136
+
*/
137
+
public function sendAsyncRequest(RequestInterface $request)
138
+
{
139
+
try {
140
+
$response = $this->client->sendRequest($request);
141
+
} catch (RequestExceptionInterface $e) {
142
+
return new HttpRejectedPromise(new RequestException($e->getMessage(), $request, $e));
143
+
} catch (NetworkExceptionInterface $e) {
144
+
return new HttpRejectedPromise(new NetworkException($e->getMessage(), $request, $e));
0 commit comments