diff --git a/CHANGELOG.md b/CHANGELOG.md index b9f24f4..27682ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Yii1 PSR Log extension ----------------------- - Enh: Added ability for global log context setup at `PsrLogger` (klimov-paul) +- Enh: Added `PsrLogger::new()` static method for a new instance creation (klimov-paul) 1.0.0, July 19, 2023 diff --git a/src/AbstractPsrLogger.php b/src/AbstractPsrLogger.php index ff2a4e2..0953374 100644 --- a/src/AbstractPsrLogger.php +++ b/src/AbstractPsrLogger.php @@ -106,4 +106,18 @@ protected function logGlobalContextResolutionError(Throwable $exception): void $this->getYiiLogger()->log($errorMessage, CLogger::LEVEL_ERROR, 'system.log'); } + + /** + * Creates new self instance. + * This method can be useful when writing chain methods calls. + * + * @since 1.0.1 + * + * @param mixed ...$args constructor arguments. + * @return static new self instance. + */ + public static function new(...$args): self + { + return new static(...$args); + } } \ No newline at end of file diff --git a/src/Logger.php b/src/Logger.php index 5ed2cdf..e99fb94 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -285,10 +285,11 @@ protected function formatLogContext(array $logContext, int $nestedLevel = 0): ar * Creates new self instance. * This method can be useful when writing chain methods calls. * + * @param mixed ...$args constructor arguments. * @return static new self instance. */ - public static function new(): self + public static function new(...$args): self { - return new static(); + return new static(...$args); } } \ No newline at end of file