mirror of
https://github.com/manualdousuario/marreta.git
synced 2025-09-01 10:10:14 +00:00
ajuste de integração com hawk
This commit is contained in:
parent
b4712928e6
commit
425c5aa151
2 changed files with 11 additions and 14 deletions
|
@ -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
|
||||
|
@ -36,11 +34,6 @@ class 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), [
|
||||
|
@ -63,6 +56,11 @@ class Logger
|
|||
*/
|
||||
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(),
|
||||
|
|
|
@ -115,9 +115,8 @@ class URLAnalyzer
|
|||
$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
|
||||
|
|
Loading…
Add table
Reference in a new issue