@@ -19,13 +19,6 @@ final class LogsHandlerTest extends TestCase
1919 protected function setUp (): void
2020 {
2121 Logs::getInstance ()->flush ();
22- }
23-
24- /**
25- * @dataProvider handleDataProvider
26- */
27- public function testHandle ($ record , Log $ expectedLog ): void
28- {
2922 $ client = ClientBuilder::create ([
3023 'enable_logs ' => true ,
3124 'before_send ' => static function () {
@@ -35,7 +28,13 @@ public function testHandle($record, Log $expectedLog): void
3528
3629 $ hub = new Hub ($ client );
3730 SentrySdk::setCurrentHub ($ hub );
31+ }
3832
33+ /**
34+ * @dataProvider handleDataProvider
35+ */
36+ public function testHandle ($ record , Log $ expectedLog ): void
37+ {
3938 $ handler = new LogsHandler ();
4039 $ handler ->handle ($ record );
4140
@@ -65,23 +64,25 @@ static function (string $key) {
6564 */
6665 public function testLogLevels ($ record , int $ countLogs ): void
6766 {
68- $ client = ClientBuilder::create ([
69- 'enable_logs ' => true ,
70- 'before_send ' => static function () {
71- return null ;
72- },
73- ])->getClient ();
74-
75- $ hub = new Hub ($ client );
76- SentrySdk::setCurrentHub ($ hub );
77-
7867 $ handler = new LogsHandler (LogLevel::warn ());
7968 $ handler ->handle ($ record );
8069
8170 $ logs = Logs::getInstance ()->aggregator ()->all ();
8271 $ this ->assertCount ($ countLogs , $ logs );
8372 }
8473
74+ public function testOriginTagAppliedWithHandler (): void
75+ {
76+ $ handler = new LogsHandler (LogLevel::warn ());
77+ $ handler ->handle (RecordFactory::create ('with origin ' , Logger::WARNING , 'channel.foo ' , [], []));
78+
79+ $ logs = Logs::getInstance ()->aggregator ()->all ();
80+ $ this ->assertCount (1 , $ logs );
81+ $ log = $ logs [0 ];
82+ $ this ->assertArrayHasKey ('sentry.origin ' , $ log ->attributes ()->toSimpleArray ());
83+ $ this ->assertSame ('auto.logger.monolog ' , $ log ->attributes ()->toSimpleArray ()['sentry.origin ' ]);
84+ }
85+
8586 public static function handleDataProvider (): iterable
8687 {
8788 yield [
0 commit comments