改名
This commit is contained in:
@@ -5,8 +5,9 @@ namespace Kiri\Error;
|
|||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Http\Aspect\OnAspectInterface;
|
||||||
|
use Http\Aspect\OnJoinPointInterface;
|
||||||
use Http\Constrict\RequestInterface;
|
use Http\Constrict\RequestInterface;
|
||||||
use Kiri\IAspect;
|
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
|
|
||||||
|
|
||||||
@@ -14,20 +15,24 @@ use Kiri\Kiri;
|
|||||||
* Class LoggerAspect
|
* Class LoggerAspect
|
||||||
* @package Kiri\Error
|
* @package Kiri\Error
|
||||||
*/
|
*/
|
||||||
class LoggerAspect implements IAspect
|
class LoggerAspect implements OnAspectInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
private float $time;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $handler
|
* @param OnJoinPointInterface $joinPoint
|
||||||
* @param array $params
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function invoke(mixed $handler, array $params = []): mixed
|
public function process(OnJoinPointInterface $joinPoint): mixed
|
||||||
{
|
{
|
||||||
return call_user_func($handler, ...$params);
|
$time = microtime(true);
|
||||||
|
|
||||||
|
$response = $joinPoint->process();
|
||||||
|
|
||||||
|
$this->print_runtime($time);
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -44,20 +49,4 @@ class LoggerAspect implements IAspect
|
|||||||
echo PHP_EOL;
|
echo PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function before(): void
|
|
||||||
{
|
|
||||||
// TODO: Implement before() method.
|
|
||||||
$this->time = microtime(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function after(mixed $response): void
|
|
||||||
{
|
|
||||||
// TODO: Implement after() method.
|
|
||||||
$this->print_runtime($this->time);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user