Files
kiri-core/kiri-engine/Error/StdoutLogger.php
T

48 lines
789 B
PHP
Raw Normal View History

2022-02-23 16:32:08 +08:00
<?php
2023-04-16 01:45:34 +08:00
declare(strict_types=1);
2022-02-23 16:32:08 +08:00
namespace Kiri\Error;
use Kiri\Abstracts\Logger;
use Kiri\Exception\ConfigException;
class StdoutLogger extends Logger implements StdoutLoggerInterface
{
2023-04-05 15:22:01 +08:00
/**
* @var array
*/
2022-02-23 16:32:08 +08:00
private array $errors = [];
/**
* @param $message
* @param string $model
* @return bool
* @throws ConfigException
*/
public function addError($message, string $model = 'app'): bool
{
$this->error($model, [$message]);
if ($message instanceof \Exception) {
$this->errors[$model] = $message->getMessage();
} else {
$this->errors[$model] = $message;
}
return false;
}
/**
* @param string $model
* @return mixed
*/
public function getLastError(string $model = 'app'): mixed
{
return $this->errors[$model] ?? 'Unknown error.';
}
}