-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from AnniWeb/master
Обновление psr/log
- Loading branch information
Showing
10 changed files
with
164 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Bx\Logger\Interfaces; | ||
|
||
use Psr\Log\LoggerInterface; | ||
|
||
interface TypedLoggerInterface extends LoggerInterface | ||
{ | ||
public function getType(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
namespace Bx\Logger; | ||
|
||
use Bx\Logger\Interfaces\TypedLoggerInterface; | ||
use Psr\Log\LoggerInterface; | ||
use Stringable; | ||
|
||
class TypedLogger implements TypedLoggerInterface | ||
{ | ||
private LoggerInterface $originalLogger; | ||
private string $type; | ||
|
||
public function __construct(LoggerInterface $logger, string $type) | ||
{ | ||
$this->originalLogger = $logger; | ||
$this->type = $type; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function emergency(Stringable|string $message, array $context = []): void | ||
{ | ||
$this->originalLogger->emergency($message, $context); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function alert(Stringable|string $message, array $context = []): void | ||
{ | ||
$this->originalLogger->alert($message, $context); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function critical(Stringable|string $message, array $context = []): void | ||
{ | ||
$this->originalLogger->critical($message, $context); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function error(Stringable|string $message, array $context = []): void | ||
{ | ||
$this->originalLogger->error($message, $context); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function warning(Stringable|string $message, array $context = []): void | ||
{ | ||
$this->originalLogger->warning($message, $context); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function notice(Stringable|string $message, array $context = []): void | ||
{ | ||
$this->originalLogger->notice($message, $context); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function info(Stringable|string $message, array $context = []): void | ||
{ | ||
$this->originalLogger->info($message, $context); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function debug(Stringable|string $message, array $context = []): void | ||
{ | ||
$this->originalLogger->debug($message, $context); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function log($level, Stringable|string $message, array $context = []): void | ||
{ | ||
$this->originalLogger->log($level, $message, $context); | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return $this->type; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Bx\Logger; | ||
|
||
use Bx\Logger\Interfaces\TypedLoggerInterface; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class TypedLoggerFactory | ||
{ | ||
/** | ||
* @param LoggerInterface $logger | ||
* @param string $type | ||
* @return TypedLoggerInterface | ||
*/ | ||
public static function createTypedLogger(LoggerInterface $logger, string $type): TypedLoggerInterface | ||
{ | ||
return new TypedLogger($logger, $type); | ||
} | ||
} |