-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add LoggerInterface and LogLocatorLogger * test
- Loading branch information
Showing
7 changed files
with
260 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace Kronos\Log; | ||
|
||
use Stringable; | ||
use Throwable; | ||
|
||
class LogLocatorLogger implements LoggerInterface | ||
{ | ||
private static ?self $instance = null; | ||
|
||
public static function getInstance(): self | ||
{ | ||
return self::$instance ??= new self(); | ||
} | ||
|
||
public function emergency(string|Stringable $message, array $context = []): void | ||
{ | ||
LogLocator::getLogger()->emergency($message, $context); | ||
} | ||
|
||
public function alert(string|Stringable $message, array $context = []): void | ||
{ | ||
LogLocator::getLogger()->alert($message, $context); | ||
} | ||
|
||
public function critical(string|Stringable $message, array $context = []): void | ||
{ | ||
LogLocator::getLogger()->critical($message, $context); | ||
} | ||
|
||
public function error(string|Stringable $message, array $context = []): void | ||
{ | ||
LogLocator::getLogger()->error($message, $context); | ||
} | ||
|
||
public function warning(string|Stringable $message, array $context = []): void | ||
{ | ||
LogLocator::getLogger()->warning($message, $context); | ||
} | ||
|
||
public function notice(string|Stringable $message, array $context = []): void | ||
{ | ||
LogLocator::getLogger()->notice($message, $context); | ||
} | ||
|
||
public function info(string|Stringable $message, array $context = []): void | ||
{ | ||
LogLocator::getLogger()->info($message, $context); | ||
} | ||
|
||
public function debug(string|Stringable $message, array $context = []): void | ||
{ | ||
LogLocator::getLogger()->debug($message, $context); | ||
} | ||
|
||
public function log($level, string|Stringable $message, array $context = []): void | ||
{ | ||
LogLocator::getLogger()->log($level, $message, $context); | ||
} | ||
|
||
public function exception(string $message, Throwable $exception, array $context = array()): void | ||
{ | ||
LogLocator::getLogger()->exception($message, $exception, $context); | ||
} | ||
|
||
public function addContext(string $key, mixed $value): void | ||
{ | ||
LogLocator::getLogger()->addContext($key, $value); | ||
} | ||
|
||
public function addContextArray(array $context): void | ||
{ | ||
LogLocator::getLogger()->addContextArray($context); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace Kronos\Log; | ||
|
||
use Throwable; | ||
|
||
interface LoggerInterface extends \Psr\Log\LoggerInterface | ||
{ | ||
/** | ||
* Log Error with exception context | ||
*/ | ||
public function exception(string $message, Throwable $exception, array $context = array()): void; | ||
|
||
public function addContext(string $key, mixed $value): void; | ||
|
||
public function addContextArray(array $context): void; | ||
} |
Oops, something went wrong.