feat(logging): migrate remaining files to app channel — all Log:: calls now use domain channels

This commit is contained in:
F4ilji
2026-07-05 23:32:01 +05:00
parent 6bc1b3e921
commit 769b2ff342
17 changed files with 50 additions and 50 deletions
@@ -66,7 +66,7 @@ class FetchEmailNewsCommand extends ConsoleCommand
return $this->handleSync($fetchEmailNewsAction, $verbose);
} catch (EmailFetchException $e) {
$this->error('❌ Ошибка Email: ' . $e->getMessage());
Log::error('[FetchEmailNewsCommand] EmailFetchException', [
Log::channel('app')->error('EmailFetchException', [
'code' => $e->getCode(),
'message' => $e->getMessage(),
]);
@@ -76,7 +76,7 @@ class FetchEmailNewsCommand extends ConsoleCommand
$this->error('❌ Критическая ошибка: ' . $e->getMessage());
$this->warn('Проверьте логи: storage/logs/laravel.log');
Log::error('[FetchEmailNewsCommand] Critical Error', [
Log::channel('app')->error('Critical Error', [
'error' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
]);
@@ -57,7 +57,7 @@ class ProcessEmailNewsJob implements ShouldQueue
*/
public function handle(FetchEmailNewsAction $fetchEmailNewsAction): void
{
Log::info('[ProcessEmailNewsJob] Начало обработки job', [
Log::channel('app')->info('Начало обработки job', [
'job_id' => $this->job?->getJobId() ?? 'unknown',
'attempt' => $this->attempts(),
'memory_limit' => ini_get('memory_limit'),
@@ -66,7 +66,7 @@ class ProcessEmailNewsJob implements ShouldQueue
// Выполняем обработку — если выбросит исключение, Laravel автоматически повторит job
$result = $fetchEmailNewsAction->run();
Log::info('[ProcessEmailNewsJob] Обработка завершена успешно', [
Log::channel('app')->info('Обработка завершена успешно', [
'job_id' => $this->job?->getJobId() ?? 'unknown',
'processed_emails' => $result['processed_emails'],
'created_posts' => $result['created_posts'],
@@ -79,7 +79,7 @@ class ProcessEmailNewsJob implements ShouldQueue
// Если были ошибки, логируем их как warning
if (!empty($result['errors'])) {
foreach ($result['errors'] as $error) {
Log::warning('[ProcessEmailNewsJob] Ошибка обработки письма', [
Log::channel('app')->warning('Ошибка обработки письма', [
'subject' => $error['email_subject'] ?? 'unknown',
'error' => $error['error'],
]);
@@ -95,7 +95,7 @@ class ProcessEmailNewsJob implements ShouldQueue
*/
public function failed(\Throwable $exception): void
{
Log::critical('[ProcessEmailNewsJob] Job окончательно провален', [
Log::channel('app')->critical('Job окончательно провален', [
'total_attempts' => $this->tries,
'error' => $exception->getMessage(),
]);
@@ -43,7 +43,7 @@ class CompressImageTask
{
$extension = strtolower($file->getClientOriginalExtension());
Log::info('[CompressImageTask] Начало обработки изображения', [
Log::channel('app')->info('Начало обработки изображения', [
'file' => $file->getClientOriginalName(),
'extension' => $extension,
'size' => $this->formatFileSize($file->getSize()),
@@ -52,7 +52,7 @@ class CompressImageTask
// Если файл уже меньше порога и это WebP - пропускаем сжатие
if ($file->getSize() <= self::SIZE_THRESHOLD && $extension === 'webp') {
Log::info('[CompressImageTask] Файл уже оптимизирован, пропускаем', [
Log::channel('app')->info('Файл уже оптимизирован, пропускаем', [
'file' => $file->getClientOriginalName(),
]);
@@ -71,7 +71,7 @@ class CompressImageTask
$originalWidth = $img->width();
$originalHeight = $img->height();
Log::info('[CompressImageTask] Исходные размеры', [
Log::channel('app')->info('Исходные размеры', [
'width' => $originalWidth,
'height' => $originalHeight,
]);
@@ -83,7 +83,7 @@ class CompressImageTask
$constraint->upsize();
});
Log::info('[CompressImageTask] Изображение ресайзнуто', [
Log::channel('app')->info('Изображение ресайзнуто', [
'new_width' => $img->width(),
'new_height' => $img->height(),
]);
@@ -99,7 +99,7 @@ class CompressImageTask
$newSize = filesize($tempPath);
Log::info('[CompressImageTask] Сжатие завершено', [
Log::channel('app')->info('Сжатие завершено', [
'original_size' => $this->formatFileSize($file->getSize()),
'compressed_size' => $this->formatFileSize($newSize),
'compression_ratio' => round((1 - $newSize / $file->getSize()) * 100, 2) . '%',
@@ -47,7 +47,7 @@ trait MemoryAwareTrait
// Логируем только если превышен порог
if ($currentMemory > $this->memoryLogThreshold) {
Log::info('[MemoryMonitor] Использование памяти', [
Log::channel('app')->info('Использование памяти', [
'context' => $context,
'current' => round($currentMemory / 1024 / 1024, 2) . 'MB',
'peak' => round($peakMemory / 1024 / 1024, 2) . 'MB',
@@ -75,7 +75,7 @@ trait MemoryAwareTrait
$memoryAfter = round(memory_get_usage(true) / 1024 / 1024, 2);
$freed = round(($memoryBefore - $memoryAfter), 2);
Log::info('[MemoryMonitor] Сборка мусора выполнена', [
Log::channel('app')->info('Сборка мусора выполнена', [
'memory_before' => $memoryBefore . 'MB',
'memory_after' => $memoryAfter . 'MB',
'freed' => $freed . 'MB',
@@ -18,7 +18,7 @@ class ParseEmailNewsController extends Controller
public function __invoke(Request $request): RedirectResponse
{
try {
Log::info('[ParseEmailNewsController] Принудительный запуск парсинга email');
Log::channel('app')->info('Принудительный запуск парсинга email');
$result = $this->fetchEmailNewsAction->run();
@@ -38,13 +38,13 @@ class ParseEmailNewsController extends Controller
"Обработано писем: {$result['processed_emails']}, но новостей не создано"
);
} catch (EmailFetchException $e) {
Log::error('[ParseEmailNewsController] EmailFetchException', [
Log::channel('app')->error('EmailFetchException', [
'error' => $e->getMessage(),
]);
return redirect()->back()->with('error', $e->getMessage());
} catch (\Exception $e) {
Log::error('[ParseEmailNewsController] Критическая ошибка', [
Log::channel('app')->error('Критическая ошибка', [
'error' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
]);
@@ -15,7 +15,7 @@ class ClearStaticSearchCacheAction
Cache::forget(self::CACHE_KEY);
return true;
} catch (\Exception $e) {
Log::error('Cache clear error: ' . $e->getMessage());
Log::channel('app')->error('Cache clear error: ' . $e->getMessage());
return false;
}
}
@@ -47,7 +47,7 @@ class SearchStaticFilesAction
return app(PaginateSearchResultsTask::class)->run($results, $page, self::PER_PAGE, $categories);
} catch (\Exception $e) {
Log::error('Search error: ' . $e->getMessage());
Log::channel('app')->error('Search error: ' . $e->getMessage());
return [
'data' => [],
'meta' => [
@@ -77,7 +77,7 @@ class SearchStaticFilesAction
return null;
} catch (\Exception $e) {
Log::error('Failed to get H1: ' . $e->getMessage());
Log::channel('app')->error('Failed to get H1: ' . $e->getMessage());
return null;
}
}
@@ -24,7 +24,7 @@ class BuildStaticFileIndexTask
$directory = public_path(self::FILES_DIR);
if (!is_dir($directory)) {
Log::error("Directory not found: {$directory}");
Log::channel('app')->error("Directory not found: {$directory}");
return [];
}
@@ -51,7 +51,7 @@ class BuildStaticFileIndexTask
return $index;
} catch (\Exception $e) {
Log::error('Index creation error: ' . $e->getMessage());
Log::channel('app')->error('Index creation error: ' . $e->getMessage());
return [];
}
});
@@ -80,7 +80,7 @@ class BuildStaticFileIndexTask
return null;
} catch (\Exception $e) {
Log::error('Failed to get H1: ' . $e->getMessage());
Log::channel('app')->error('Failed to get H1: ' . $e->getMessage());
return null;
}
}
@@ -14,7 +14,7 @@ class GetStaticFileCategoriesTask
try {
$file = public_path(self::FILES_DIR . '/' . 'index.html');
if (!file_exists($file)) {
Log::error("Category index file not found: {$file}");
Log::channel('app')->error("Category index file not found: {$file}");
return [];
}
@@ -24,7 +24,7 @@ class GetStaticFileCategoriesTask
$dropdownMenu = $document->first('ul.dropdown-menu');
if ($dropdownMenu === null) {
Log::warning("Dropdown menu not found in category index file: {$file}");
Log::channel('app')->warning("Dropdown menu not found in category index file: {$file}");
return [];
}
@@ -38,7 +38,7 @@ class GetStaticFileCategoriesTask
return $categories;
} catch (\Exception $e) {
Log::error('Error extracting categories: ' . $e->getMessage());
Log::channel('app')->error('Error extracting categories: ' . $e->getMessage());
return [];
}
}