From 491f8b4fd0193f16bd0baf99b07e5070e6e29d31 Mon Sep 17 00:00:00 2001 From: guandeng Date: Tue, 26 Dec 2023 22:54:47 +0800 Subject: [PATCH] Add telescope getPath method (#510) --- src/Aspect/LogAspect.php | 2 +- src/Listener/DbQueryListener.php | 2 +- src/Telescope.php | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Aspect/LogAspect.php b/src/Aspect/LogAspect.php index c5f161d..b1398a8 100644 --- a/src/Aspect/LogAspect.php +++ b/src/Aspect/LogAspect.php @@ -43,7 +43,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint) $level = $level instanceof UnitEnum ? (int) $level->value : (int) $level; /* @phpstan-ignore-line */ $message = $proceedingJoinPoint->arguments['keys']['message']; $context = $proceedingJoinPoint->arguments['keys']['context']; - if (Str::contains($message, 'telescope')) { + if (Str::contains($message, Telescope::getPath())) { return; } $name = $proceedingJoinPoint->getInstance()->getName(); diff --git a/src/Listener/DbQueryListener.php b/src/Listener/DbQueryListener.php index 9cc3348..07d6830 100644 --- a/src/Listener/DbQueryListener.php +++ b/src/Listener/DbQueryListener.php @@ -47,7 +47,7 @@ public function process(object $event): void $sql = Str::replaceFirst('?', "'{$value}'", $sql); } } - if (Str::contains($sql, 'telescope')) { + if (Str::contains($sql, Telescope::getPath())) { return; } $optionSlow = Telescope::getQuerySlow(); diff --git a/src/Telescope.php b/src/Telescope.php index da8d915..230fd31 100644 --- a/src/Telescope.php +++ b/src/Telescope.php @@ -138,6 +138,11 @@ public static function getQuerySlow(): int return static::getConfig()->getDatabaseQuerySlow(); } + public static function getPath(): string + { + return static::getConfig()->getPath(); + } + /** * Add a callback that adds tags to the record. *