mirror of
https://github.com/appwrite/appwrite
synced 2026-05-22 16:38:32 +00:00
Add logging functionality to Action class with dump method and refactor disableSubqueries to use class filters
This commit is contained in:
parent
3cd31e2c06
commit
c479a11850
1 changed files with 33 additions and 5 deletions
|
|
@ -3,7 +3,10 @@
|
|||
namespace Appwrite\Platform;
|
||||
|
||||
use Swoole\Coroutine as Co;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Platform\Action as UtopiaAction;
|
||||
|
||||
|
|
@ -16,6 +19,12 @@ class Action extends UtopiaAction
|
|||
*/
|
||||
protected mixed $logError;
|
||||
|
||||
protected array $filters = [
|
||||
'subQueryKeys', 'subQueryWebhooks', 'subQueryPlatforms', 'subQueryProjectVariables', 'subQueryBlocks', 'subQueryDevKeys', // Project
|
||||
'subQueryAuthenticators', 'subQuerySessions', 'subQueryTokens', 'subQueryChallenges', 'subQueryMemberships', 'subQueryTargets', 'subQueryTopicTargets',// Users
|
||||
'subQueryVariables', // Sites
|
||||
];
|
||||
|
||||
/**
|
||||
* Foreach Document
|
||||
* Call provided callback for each document in the collection
|
||||
|
|
@ -90,11 +99,7 @@ class Action extends UtopiaAction
|
|||
|
||||
public function disableSubqueries()
|
||||
{
|
||||
$filters = [
|
||||
'subQueryKeys', 'subQueryWebhooks', 'subQueryPlatforms', 'subQueryProjectVariables', 'subQueryBlocks', 'subQueryDevKeys', // Project
|
||||
'subQueryAuthenticators', 'subQuerySessions', 'subQueryTokens', 'subQueryChallenges', 'subQueryMemberships', 'subQueryTargets', 'subQueryTopicTargets',// Users
|
||||
'subQueryVariables', // Sites
|
||||
];
|
||||
$filters = $this->filters;
|
||||
|
||||
foreach ($filters as $filter) {
|
||||
Database::addFilter(
|
||||
|
|
@ -108,4 +113,27 @@ class Action extends UtopiaAction
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function dump(string $method, string $log, string $type = 'info', ?Document $project = null, string $collectionId = '')
|
||||
{
|
||||
if (empty($project)) {
|
||||
$project = new Document([]);
|
||||
}
|
||||
switch ($type) {
|
||||
case 'success':
|
||||
Console::success("[" . DateTime::now() . "] " . $method . ' ' . $type . ' ' . $project->getSequence() . ' ' . $project->getId() . ' ' . $collectionId . ' ' . $log);
|
||||
break;
|
||||
case 'error':
|
||||
Console::error("[" . DateTime::now() . "] " . $method . ' ' . $type . ' ' . $project->getSequence() . ' ' . $project->getId() . ' ' . $collectionId . ' ' . $log);
|
||||
break;
|
||||
case 'log':
|
||||
Console::log("[" . DateTime::now() . "] " . $method . ' ' . $type . ' ' . $project->getSequence() . ' ' . $project->getId() . ' ' . $collectionId . ' ' . $log);
|
||||
break;
|
||||
case 'warning':
|
||||
Console::warning("[" . DateTime::now() . "] " . $method . ' ' . $type . ' ' . $project->getSequence() . ' ' . $project->getId() . ' ' . $collectionId . ' ' . $log);
|
||||
break;
|
||||
default:
|
||||
Console::info("[" . DateTime::now() . "] " . $method . ' ' . $type . ' ' . $project->getSequence() . ' ' . $project->getId() . ' ' . $collectionId . ' ' . $log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue