Skip to content

Commit

Permalink
chore: use correct log level
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Nov 25, 2024
1 parent 78e3ea1 commit f7c7fd4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion classes/ColdTrick/OpenSearch/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use ColdTrick\OpenSearch\Di\SearchService;
use Elgg\Database\QueryBuilder;
use OpenSearch\Common\Exceptions\OpenSearchException;
use Psr\Log\LogLevel;

/**
* Cron handler
Expand Down Expand Up @@ -189,7 +190,7 @@ function (QueryBuilder $qb, $main_alias) {
});
} catch (OpenSearchException $e) {
// probably reached the end of the scroll
// elgg_log('OpenSearch cleanup: ' . $e->getMessage(), 'ERROR');
// elgg_log('OpenSearch cleanup: ' . $e->getMessage(), LogLevel::ERROR);
}

// clear scroll
Expand Down
3 changes: 2 additions & 1 deletion classes/ColdTrick/OpenSearch/Di/IndexingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Elgg\Database\QueryBuilder;
use Elgg\Cli\Progress;
use OpenSearch\Common\Exceptions\OpenSearchException;
use Psr\Log\LogLevel;
use Symfony\Component\Console\Helper\ProgressBar;

/**
Expand Down Expand Up @@ -301,7 +302,7 @@ protected function processBulkIndexEntities(array $entities): void {
$this->skip_guids[] = $guid;

$error = elgg_extract('error', elgg_extract('index', $item));
elgg_log("OpenSearch failed to index {$guid} with error [{$status}][{$error['type']}]: {$error['reason']}", 'WARNING');
elgg_log("OpenSearch failed to index {$guid} with error [{$status}][{$error['type']}]: {$error['reason']}", LogLevel::WARNING);
continue;
}

Expand Down
3 changes: 2 additions & 1 deletion classes/ColdTrick/OpenSearch/SearchEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use ColdTrick\OpenSearch\Di\SearchService;
use Elgg\Exceptions\ExceptionInterface;
use Elgg\Exceptions\UnexpectedValueException;
use Psr\Log\LogLevel;

/**
* Listen to different search events
Expand Down Expand Up @@ -693,7 +694,7 @@ public static function sourceToEntity(\Elgg\Event $event): ?\ElggEntity {
try {
return _elgg_services()->entityTable->rowToElggStar($row);
} catch (ExceptionInterface $e) {
elgg_log($e->getMessage(), 'NOTICE');
elgg_log($e->getMessage(), LogLevel::NOTICE);
}

return null;
Expand Down
5 changes: 3 additions & 2 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Elgg\Database\Select;
use Elgg\Exceptions\ExceptionInterface;
use Elgg\Values;
use Psr\Log\LogLevel;

/**
* Get the type/subtypes to index in OpenSearch
Expand Down Expand Up @@ -172,7 +173,7 @@ function opensearch_add_document_for_deletion(int $guid, array $info, mixed $tim
try {
$queue = DeleteQueue::instance();
} catch (\Exception $e) {
elgg_log($e, 'WARNING');
elgg_log($e, LogLevel::WARNING);
return;
}

Expand Down Expand Up @@ -224,7 +225,7 @@ function opensearch_get_documents_for_deletion(): array {
try {
$queue = DeleteQueue::instance();
} catch (ExceptionInterface $e) {
elgg_log($e, 'WARNING');
elgg_log($e, LogLevel::WARNING);
return [];
}

Expand Down
3 changes: 2 additions & 1 deletion views/default/forms/opensearch/admin_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use ColdTrick\OpenSearch\Di\IndexManagementService;
use Elgg\Exceptions\ExceptionInterface;
use Psr\Log\LogLevel;

$index_client = IndexManagementService::instance();
if (!$index_client->isClientReady()) {
Expand All @@ -20,7 +21,7 @@
try {
$status = $index_client->getIndexStatus();
} catch (ExceptionInterface $e) {
elgg_log($e, 'ERROR');
elgg_log($e, LogLevel::ERROR);

echo elgg_echo('opensearch:error:no_index');
return;
Expand Down

0 comments on commit f7c7fd4

Please sign in to comment.