eee
This commit is contained in:
@@ -89,7 +89,7 @@ class ErrorHandler extends Component implements ErrorInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$this->getLogger()->failure($lastError['message'] . PHP_EOL);
|
||||
$this->getLogger()->logCategory($lastError['message'] . PHP_EOL);
|
||||
|
||||
event(new OnSystemError());
|
||||
}
|
||||
@@ -104,7 +104,7 @@ class ErrorHandler extends Component implements ErrorInterface
|
||||
{
|
||||
$this->category = 'exception';
|
||||
|
||||
$this->getLogger()->failure($exception);
|
||||
$this->getLogger()->logCategory($exception);
|
||||
|
||||
event(new OnSystemError());
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use Monolog\Formatter\LineFormatter;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Logger;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
|
||||
|
||||
/**
|
||||
@@ -67,31 +68,32 @@ class StdoutLogger extends Component
|
||||
* @param string $model
|
||||
* @return bool
|
||||
*/
|
||||
public function failure($message, string $model = 'app'): bool
|
||||
public function logCategory($message, string $model = 'app'): bool
|
||||
{
|
||||
if ($message instanceof \Exception) {
|
||||
$this->errors[$model] = $message->getMessage();
|
||||
} else {
|
||||
$this->errors[$model] = $message;
|
||||
}
|
||||
return $this->dump($message);
|
||||
$this->println($message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $message
|
||||
* @return bool
|
||||
*/
|
||||
protected function dump($message): bool
|
||||
{
|
||||
$message = throwable($message);
|
||||
if (str_contains($message, 'inotify_rm_watch')) {
|
||||
return false;
|
||||
}
|
||||
file_put_contents('php://output', '[' . date('Y-m-d H:i:s') . '] ' . $message, FILE_APPEND);
|
||||
$this->error($message, []);
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @param Throwable $exception
|
||||
* @param array $data
|
||||
* @param mixed|null $result
|
||||
* @return bool
|
||||
*/
|
||||
public function json_log(Throwable $exception, array $data = [], mixed $result = null): mixed
|
||||
{
|
||||
json_log($exception, $data);
|
||||
|
||||
$this->println($exception->getMessage());
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -118,9 +120,10 @@ class StdoutLogger extends Component
|
||||
} else if (method_exists($this, $name)) {
|
||||
$this->{$name}(...$arguments);
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
file_put_contents('php://output', '[' . date('Y-m-d H:i:s') . '] ' . $exception->getMessage(), FILE_APPEND);
|
||||
}
|
||||
} catch (Throwable $exception) {
|
||||
$this->println($exception->getMessage());
|
||||
$this->json_log($exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user