Skip to content

Commit cc7ae9a

Browse files
Ignore log breadcrumbs when null is logged in Laravel (#345)
* Ignore breadcrumbs when null is logged in Laravel * CS * Add changelog entry Co-authored-by: Alex Bouma <[email protected]>
1 parent 7460a08 commit cc7ae9a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Add `send_default_pii` option by default to published config file (#340)
66
- Update `.gitattributes` to exclude more files from dist release (#341)
7+
- Ignore log breadcrumbs when `null` is the message logged (#345)
78
- Fixed scope data in queue jobs being lost in some cases (#351)
89

910
## 1.7.1

src/Sentry/Laravel/EventHandler.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,23 @@ protected function messageLoggedHandler(MessageLogged $logEntry)
313313
/**
314314
* Helper to add an log breadcrumb.
315315
*
316-
* @param string $level Log level. May be any standard.
317-
* @param string $message Log message.
318-
* @param array $context Log context.
316+
* @param string $level Log level. May be any standard.
317+
* @param string|null $message Log message.
318+
* @param array $context Log context.
319319
*/
320-
private function addLogBreadcrumb(string $level, string $message, array $context = []): void
320+
private function addLogBreadcrumb(string $level, ?string $message, array $context = []): void
321321
{
322322
if (!$this->recordLaravelLogs) {
323323
return;
324324
}
325325

326+
// A log message with `null` as value will not be recorded by Laravel
327+
// however empty strings are logged so we mimick that behaviour to
328+
// check for `null` to stay consistent with how Laravel logs it
329+
if ($message === null) {
330+
return;
331+
}
332+
326333
Integration::addBreadcrumb(new Breadcrumb(
327334
$this->logLevelToBreadcrumbLevel($level),
328335
Breadcrumb::TYPE_DEFAULT,

0 commit comments

Comments
 (0)