Skip to content

Commit b84bb85

Browse files
committed
Store tags with logs.
1 parent 429626b commit b84bb85

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

database/migrations/create_laravel_developer_table.php.stub

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class CreateLaravelDeveloperTable extends Migration
1313
$table->uuid('uuid');
1414

1515
$table->string('name')->nullable();
16+
$table->string('tags')->nullable();
1617
$table->text('payload')->nullable();
1718
$table->text('exception')->nullable();
1819
$table->text('previous')->nullable();

src/Models/ExceptionLog.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* @property string $file
2222
* @property string $line
2323
* @property string $code
24+
* @property string $tags
2425
* @property array $exception
2526
* @property array $previous
2627
* @property array|mixed $payload
@@ -58,6 +59,7 @@ public static function makeFromDevLog(DevLog $log): self
5859
'uuid' => (string) Str::uuid(),
5960
'name' => $log->name,
6061
'payload' => $log->payload,
62+
'tags' => $log->tags,
6163
]);
6264
}
6365

src/Notifications/DevLog.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ class DevLog
1010

1111
public string $name;
1212

13-
public function __construct(string $name = 'Dev Log', array $payload = [])
13+
public ?string $tags;
14+
15+
public function __construct(string $name = 'Dev Log', array $payload = [], ?string $tags = null)
1416
{
1517
$this->payload = $payload;
1618
$this->name = $name;
19+
$this->tags = $tags;
1720
}
1821

1922
public function setPayload(array $payload): self
@@ -30,9 +33,16 @@ public function setName(string $name): self
3033
return $this;
3134
}
3235

33-
public static function make(string $name = 'Dev Log', array $payload = null): self
36+
public function setTags(string $tags): self
37+
{
38+
$this->tags = $tags;
39+
40+
return $this;
41+
}
42+
43+
public static function make(string $name = 'Dev Log', array $payload = null, ?string $tags = null): self
3444
{
35-
return new static($name, $payload);
45+
return new static($name, $payload, $tags);
3646
}
3747

3848
public function getPayload(): array

tests/Helpers/DevLogHelperTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,17 @@ public function test_dev_log_can_store_payload(): void
2727
$exceptionLog->payload
2828
);
2929
}
30+
31+
public function test_dev_log_can_store_tags(): void
32+
{
33+
$payload = ['a' => 'b'];
34+
35+
$this->assertInstanceOf(DevLog::class, $log = devLog('Dev Log', $payload, 'error'));
36+
37+
$log->__destruct();
38+
39+
$this->assertDatabaseHas('exception_logs', [
40+
'tags' => 'error',
41+
]);
42+
}
3043
}

0 commit comments

Comments
 (0)