Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate logged errors and warnings #293

Merged
merged 4 commits into from
Jun 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Deduplicate logged errors and warnings
  • Loading branch information
rhertogh committed Jun 17, 2023
commit 908feb47d05e24c1c0bfa82bc0198acc96c5e54a
23 changes: 17 additions & 6 deletions commands/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,27 @@ public function actionIndex(array $sourceDirs, $targetDir)
$renderer->controller = $this;
$renderer->render($context, $targetDir);

$hashAlgo = in_array('xxh3', hash_algos()) ? 'xxh3' : 'crc32';
if (!empty($context->errors)) {
ArrayHelper::multisort($context->errors, 'file');
file_put_contents($targetDir . '/errors.txt', print_r($context->errors, true));
$this->stdout(count($context->errors) . " errors have been logged to $targetDir/errors.txt\n", Console::FG_RED, Console::BOLD);
$errors = [];
foreach ($context->errors as $error) {
$errors[hash($hashAlgo, json_encode($error))] = $error;
}
$errors = array_values($errors);
ArrayHelper::multisort($errors, 'file');
file_put_contents($targetDir . '/errors.txt', print_r($errors, true));
$this->stdout(count($errors) . " errors have been logged to $targetDir/errors.txt\n", Console::FG_RED, Console::BOLD);
}

if (!empty($context->warnings)) {
ArrayHelper::multisort($context->warnings, 'file');
file_put_contents($targetDir . '/warnings.txt', print_r($context->warnings, true));
$this->stdout(count($context->warnings) . " warnings have been logged to $targetDir/warnings.txt\n", Console::FG_YELLOW, Console::BOLD);
$warnings = [];
foreach ($context->warnings as $warning) {
$warnings[hash($hashAlgo, json_encode($warning))] = $warning;
}
$warnings = array_values($warnings);
ArrayHelper::multisort($warnings, 'file');
file_put_contents($targetDir . '/warnings.txt', print_r($warnings, true));
$this->stdout(count($warnings) . " warnings have been logged to $targetDir/warnings.txt\n", Console::FG_YELLOW, Console::BOLD);
}

return 0;
Expand Down
Loading