1
0
Fork 0
mirror of synced 2024-06-01 10:29:48 +12:00

Fix error logging

This commit is contained in:
Matej Bačo 2023-05-24 21:07:41 +02:00
parent 0244154017
commit 3614cb384a
4 changed files with 14 additions and 14 deletions

View file

@ -129,7 +129,7 @@ $server
throw $error;
}
if ($error->getCode() >= 500 || $error->getCode() === 0) {
if ($logger && ($error->getCode() >= 500 || $error->getCode() === 0)) {
$log->setNamespace("appwrite-worker");
$log->setServer(\gethostname());
$log->setVersion($version);
@ -147,7 +147,8 @@ $server
$isProduction = App::getEnv('_APP_ENV', 'development') === 'production';
$log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING);
$logger->addLog($log);
$responseCode = $logger->addLog($log);
Console::info('Usage stats log pushed with status code: ' . $responseCode);
}
Console::error('[Error] Type: ' . get_class($error));

View file

@ -43,6 +43,7 @@ Server::setResource('execute', function () {
string $executionId = null,
) {
$error = null; // Used to re-throw at the end to trigger Logger (Sentry)
$errorCode = 0;
$user ??= new Document();
$functionId = $function->getId();
@ -160,12 +161,8 @@ Server::setResource('execute', function () {
->setAttribute('statusCode', $th->getCode())
->setAttribute('stderr', $th->getMessage());
Console::error($th->getTraceAsString());
Console::error($th->getFile());
Console::error($th->getLine());
Console::error($th->getMessage());
$error = $th->getMessage();
$errorCode = $th->getCode();
}
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
@ -228,7 +225,7 @@ Server::setResource('execute', function () {
}
if (!empty($error)) {
throw new Exception($error);
throw new Exception($error, $errorCode);
}
};
});

12
composer.lock generated
View file

@ -2425,16 +2425,16 @@
},
{
"name": "utopia-php/queue",
"version": "0.5.2",
"version": "0.5.3",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/queue.git",
"reference": "310271c5cd477541208d7fa74a4dea64df8e04a0"
"reference": "8e8b6cb27172713fe5d8b7b092ce68516caf129a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/queue/zipball/310271c5cd477541208d7fa74a4dea64df8e04a0",
"reference": "310271c5cd477541208d7fa74a4dea64df8e04a0",
"url": "https://api.github.com/repos/utopia-php/queue/zipball/8e8b6cb27172713fe5d8b7b092ce68516caf129a",
"reference": "8e8b6cb27172713fe5d8b7b092ce68516caf129a",
"shasum": ""
},
"require": {
@ -2480,9 +2480,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/queue/issues",
"source": "https://github.com/utopia-php/queue/tree/0.5.2"
"source": "https://github.com/utopia-php/queue/tree/0.5.3"
},
"time": "2023-03-07T08:54:10+00:00"
"time": "2023-05-24T19:06:04+00:00"
},
{
"name": "utopia-php/registry",

View file

@ -482,6 +482,8 @@ services:
- _APP_USAGE_STATS
- DOCKERHUB_PULL_USERNAME
- DOCKERHUB_PULL_PASSWORD
- _APP_LOGGING_CONFIG
- _APP_LOGGING_PROVIDER
appwrite-worker-mails:
entrypoint: worker-mails