redact($context); Log::info("[{$this->jobLabel()}] {$title}", $safe); $this->telegram->SendJobRunInfo($this->jobLabel(), 'step: ' . $title, $safe); } public function success(string $title, array $context = []): void { $safe = $this->redact($context); Log::info("[{$this->jobLabel()}] {$title}", $safe); $this->telegram->SendJobRunInfo($this->jobLabel(), 'success: ' . $title, $safe); } public function warning(string $title, array $context = []): void { $safe = $this->redact($context); Log::warning("[{$this->jobLabel()}] {$title}", $safe); $this->telegram->SendErrorMessage([ 'job' => $this->jobLabel(), 'level' => 'warning', 'title' => $title, 'context' => $safe, ]); } public function error(string $title, array $context = []): void { $safe = $this->redact($context); Log::error("[{$this->jobLabel()}] {$title}", $safe); $this->telegram->SendErrorMessage([ 'job' => $this->jobLabel(), 'level' => 'error', 'title' => $title, 'context' => $safe, ]); } public function exception(string $title, Throwable $e, array $context = []): void { $safe = $this->redact($context); Log::error("[{$this->jobLabel()}] {$title}: " . $e->getMessage(), $safe + [ 'exception' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTraceAsString(), ]); $this->telegram->SendErrorMessage([ 'job' => $this->jobLabel(), 'level' => 'exception', 'title' => $title, 'error' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'context' => $safe, 'trace' => substr($e->getTraceAsString(), 0, 500), ]); } private function jobLabel(): string { return self::JOB_NAME; } private function redact(array $context): array { foreach ($context as $key => $value) { if (is_array($value)) { $context[$key] = $this->redact($value); continue; } if (in_array(strtolower((string) $key), array_map('strtolower', self::REDACTED_KEYS), true)) { $context[$key] = '***'; } } return $context; } }