This commit is contained in:
2023-12-13 18:19:36 +08:00
parent d28af2fa09
commit 8685e039a4
+6 -15
View File
@@ -131,7 +131,9 @@ class Command extends Component
} catch (Throwable $throwable) {
if ($this->isRefresh($throwable)) return $this->search($method);
return $this->println($throwable)->failure($throwable->getMessage(), 'mysql');
$errorMsg = $this->sql . '.' . json_encode($this->params) . PHP_EOL . $throwable->getMessage();
return $this->getLogger()->failure($errorMsg, 'mysql');
} finally {
$this->connection->release($client);
}
@@ -170,26 +172,15 @@ class Command extends Component
} catch (Throwable $throwable) {
if ($this->isRefresh($throwable)) return $this->_prepare();
return $this->println($throwable)->failure($throwable->getMessage(), 'mysql');
$errorMsg = $this->sql . '.' . json_encode($this->params) . PHP_EOL . $throwable->getMessage();
return $this->getLogger()->failure($errorMsg, 'mysql');
} finally {
$this->connection->release($client);
}
}
/**
* @param Throwable $throwable
* @return StdoutLogger
*/
protected function println(Throwable $throwable): StdoutLogger
{
$logger = $this->getLogger();
$error = $this->sql . '.' . json_encode($this->params) . PHP_EOL . throwable($throwable);
file_put_contents('php://output', '[' . date('Y-m-d H:i:s') . '] ' . $error, FILE_APPEND);
return $logger;
}
/**
* @param Throwable $throwable
* @return bool