Skip to content

Commit

Permalink
ajuste de integração com hawk
Browse files Browse the repository at this point in the history
  • Loading branch information
altendorfme committed Dec 20, 2024
1 parent b471292 commit 425c5aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
20 changes: 9 additions & 11 deletions app/inc/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ class Logger

private function __construct()
{
// Inicializa o Hawk apenas se houver um token configurado
if (!empty(HAWK_TOKEN)) {
Catcher::init([
'integrationToken' => HAWK_TOKEN,
]);
}
// Inicializa o Hawk
Catcher::init([
'integrationToken' => HAWK_TOKEN,
]);
}

public static function getInstance(): Logger
Expand All @@ -36,11 +34,6 @@ public static function getInstance(): Logger
*/
public function error(string $message, array $context = [], string $type = 'WARNING'): void
{
// Se não houver token do Hawk configurado, não gera log
if (empty(HAWK_TOKEN)) {
return;
}

// Registra no Hawk
try {
Catcher::get()->sendException(new Exception($message), [
Expand All @@ -63,6 +56,11 @@ public function error(string $message, array $context = [], string $type = 'WARN
*/
public function log(string $url, string $error_group, string $message_error = '', string $type = 'WARNING'): void
{
// Se não houver token do Hawk configurado, não gera log
if (empty(HAWK_TOKEN)) {
return;
}

$this->error($error_group, [
'url' => $url,
'timestamp' => time(),
Expand Down
5 changes: 2 additions & 3 deletions app/inc/URLAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ public function analyze($url)
$host = preg_replace('/^www\./', '', $host);

if (in_array($host, BLOCKED_DOMAINS)) {
$error = 'BLOCKED_DOMAINS';
Logger::getInstance()->log($cleanUrl, $error);
throw new Exception($error);
Logger::getInstance()->log($cleanUrl, 'BLOCKED_DOMAIN');
throw new Exception('Este domínio está bloqueado para extração.');
}

// 4. Verifica se deve usar Selenium
Expand Down

0 comments on commit 425c5aa

Please sign in to comment.