feat(logging): migrate VikonIntegration to vikon channel
This commit is contained in:
@@ -88,7 +88,7 @@ class CheckAccessAction
|
|||||||
'parts' => $partsByModule,
|
'parts' => $partsByModule,
|
||||||
];
|
];
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('Vikon access check failed', ['error' => $e->getMessage()]);
|
Log::channel('vikon')->error('Vikon access check failed', ['error' => $e->getMessage()]);
|
||||||
return [
|
return [
|
||||||
'has_access' => false,
|
'has_access' => false,
|
||||||
'error' => 'Не удалось проверить права: ' . $e->getMessage(),
|
'error' => 'Не удалось проверить права: ' . $e->getMessage(),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CheckVersionAction
|
|||||||
'has_update' => $latest && version_compare($latest, $this->currentVersion, '>'),
|
'has_update' => $latest && version_compare($latest, $this->currentVersion, '>'),
|
||||||
];
|
];
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('Version check failed', ['error' => $e->getMessage()]);
|
Log::channel('vikon')->warning('Version check failed', ['error' => $e->getMessage()]);
|
||||||
return [
|
return [
|
||||||
'current_version' => $this->currentVersion,
|
'current_version' => $this->currentVersion,
|
||||||
'latest_version' => null,
|
'latest_version' => null,
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ class SyncFilesAction
|
|||||||
File::makeDirectory($modulePath, 0755, true, true);
|
File::makeDirectory($modulePath, 0755, true, true);
|
||||||
File::makeDirectory($filesDir, 0755, true, true);
|
File::makeDirectory($filesDir, 0755, true, true);
|
||||||
|
|
||||||
Log::info('Vikon FM: starting sync', ['module' => $moduleId]);
|
Log::channel('vikon')->info('Vikon FM: starting sync', ['module' => $moduleId]);
|
||||||
|
|
||||||
$dirIds = $this->getUsedDirNames($moduleId, $accessToken);
|
$dirIds = $this->getUsedDirNames($moduleId, $accessToken);
|
||||||
Log::info('Vikon FM: dir identifiers', ['count' => count($dirIds)]);
|
Log::channel('vikon')->info('Vikon FM: dir identifiers', ['count' => count($dirIds)]);
|
||||||
|
|
||||||
$synced = 0;
|
$synced = 0;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ class SyncFilesAction
|
|||||||
$newSynced = $this->syncNewFiles($moduleId, $accessToken, $filesDir);
|
$newSynced = $this->syncNewFiles($moduleId, $accessToken, $filesDir);
|
||||||
|
|
||||||
$total = $synced + $newSynced;
|
$total = $synced + $newSynced;
|
||||||
Log::info('Vikon FM: sync complete', ['downloaded' => $synced, 'new' => $newSynced]);
|
Log::channel('vikon')->info('Vikon FM: sync complete', ['downloaded' => $synced, 'new' => $newSynced]);
|
||||||
return "Синхронизировано: {$total} файлов";
|
return "Синхронизировано: {$total} файлов";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ class SyncFilesAction
|
|||||||
file_put_contents($filesDir . '/' . $name, $content);
|
file_put_contents($filesDir . '/' . $name, $content);
|
||||||
$synced++;
|
$synced++;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('Vikon FM: root download failed', ['identity' => $identity, 'error' => $e->getMessage()]);
|
Log::channel('vikon')->warning('Vikon FM: root download failed', ['identity' => $identity, 'error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $synced;
|
return $synced;
|
||||||
@@ -138,7 +138,7 @@ class SyncFilesAction
|
|||||||
file_put_contents($targetDir . '/' . $name, $content);
|
file_put_contents($targetDir . '/' . $name, $content);
|
||||||
$synced++;
|
$synced++;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('Vikon FM: sub download failed', ['identity' => $identity, 'error' => $e->getMessage()]);
|
Log::channel('vikon')->warning('Vikon FM: sub download failed', ['identity' => $identity, 'error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $synced;
|
return $synced;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class UpdateCoreAction
|
|||||||
$modulePath = $this->basePath . '/' . $config['path'];
|
$modulePath = $this->basePath . '/' . $config['path'];
|
||||||
$tempPath = $this->storagePath . '/temp/' . $config['path'];
|
$tempPath = $this->storagePath . '/temp/' . $config['path'];
|
||||||
|
|
||||||
Log::info('Vikon: starting full update', ['module' => $moduleId]);
|
Log::channel('vikon')->info('Vikon: starting full update', ['module' => $moduleId]);
|
||||||
|
|
||||||
$this->downloadCore($moduleId, $modulePath, $tempPath, $accessToken);
|
$this->downloadCore($moduleId, $modulePath, $tempPath, $accessToken);
|
||||||
$this->syncFromFM($moduleId, $modulePath, $accessToken);
|
$this->syncFromFM($moduleId, $modulePath, $accessToken);
|
||||||
@@ -35,7 +35,7 @@ class UpdateCoreAction
|
|||||||
// Update version file from API
|
// Update version file from API
|
||||||
$this->updateVersionFile($accessToken);
|
$this->updateVersionFile($accessToken);
|
||||||
|
|
||||||
Log::info('Vikon: full update complete', ['module' => $config['name']]);
|
Log::channel('vikon')->info('Vikon: full update complete', ['module' => $config['name']]);
|
||||||
return 'Модуль "' . $config['name'] . '" полностью обновлён.';
|
return 'Модуль "' . $config['name'] . '" полностью обновлён.';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,13 +56,13 @@ class UpdateCoreAction
|
|||||||
$zipFile
|
$zipFile
|
||||||
);
|
);
|
||||||
|
|
||||||
Log::info('Vikon: ZIP downloaded', ['size' => filesize($zipFile), 'module' => $moduleId]);
|
Log::channel('vikon')->info('Vikon: ZIP downloaded', ['size' => filesize($zipFile), 'module' => $moduleId]);
|
||||||
|
|
||||||
$this->extractZip($zipFile, $tempPath);
|
$this->extractZip($zipFile, $tempPath);
|
||||||
|
|
||||||
// Log what was extracted
|
// Log what was extracted
|
||||||
$extracted = array_map(fn($f) => basename($f), File::allFiles($tempPath));
|
$extracted = array_map(fn($f) => basename($f), File::allFiles($tempPath));
|
||||||
Log::info('Vikon: extracted files', ['count' => count($extracted), 'sample' => array_slice($extracted, 0, 10)]);
|
Log::channel('vikon')->info('Vikon: extracted files', ['count' => count($extracted), 'sample' => array_slice($extracted, 0, 10)]);
|
||||||
|
|
||||||
$blocked = $this->fs->validateFileTypes($tempPath);
|
$blocked = $this->fs->validateFileTypes($tempPath);
|
||||||
if (!empty($blocked)) {
|
if (!empty($blocked)) {
|
||||||
@@ -74,7 +74,7 @@ class UpdateCoreAction
|
|||||||
File::makeDirectory($modulePath, 0755, true, true);
|
File::makeDirectory($modulePath, 0755, true, true);
|
||||||
$this->copyFiles($syncSource, $modulePath);
|
$this->copyFiles($syncSource, $modulePath);
|
||||||
|
|
||||||
Log::info('Vikon: core downloaded', ['module' => $moduleId]);
|
Log::channel('vikon')->info('Vikon: core downloaded', ['module' => $moduleId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function syncFromFM(int $moduleId, string $modulePath, string $accessToken): void
|
private function syncFromFM(int $moduleId, string $modulePath, string $accessToken): void
|
||||||
@@ -84,7 +84,7 @@ class UpdateCoreAction
|
|||||||
File::makeDirectory($filesDir, 0755, true, true);
|
File::makeDirectory($filesDir, 0755, true, true);
|
||||||
|
|
||||||
$dirIds = $this->getUsedDirNames($moduleId, $accessToken);
|
$dirIds = $this->getUsedDirNames($moduleId, $accessToken);
|
||||||
Log::info('Vikon FM: dir identifiers', ['count' => count($dirIds), 'dirs' => $dirIds]);
|
Log::channel('vikon')->info('Vikon FM: dir identifiers', ['count' => count($dirIds), 'dirs' => $dirIds]);
|
||||||
|
|
||||||
$synced = 0;
|
$synced = 0;
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ class UpdateCoreAction
|
|||||||
|
|
||||||
$newSynced = $this->syncNewFiles($moduleId, $accessToken, $filesDir);
|
$newSynced = $this->syncNewFiles($moduleId, $accessToken, $filesDir);
|
||||||
|
|
||||||
Log::info('Vikon FM: sync done', ['synced' => $synced, 'new' => $newSynced]);
|
Log::channel('vikon')->info('Vikon FM: sync done', ['synced' => $synced, 'new' => $newSynced]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function syncRootDir(int $moduleId, string $filesDir, string $accessToken): int
|
private function syncRootDir(int $moduleId, string $filesDir, string $accessToken): int
|
||||||
@@ -141,11 +141,11 @@ class UpdateCoreAction
|
|||||||
file_put_contents($filesDir . '/' . $name, $content);
|
file_put_contents($filesDir . '/' . $name, $content);
|
||||||
$synced++;
|
$synced++;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('Vikon FM: root download failed', ['identity' => $identity, 'error' => $e->getMessage()]);
|
Log::channel('vikon')->warning('Vikon FM: root download failed', ['identity' => $identity, 'error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info('Vikon FM: root dir stats', [
|
Log::channel('vikon')->info('Vikon FM: root dir stats', [
|
||||||
'server' => $serverCount,
|
'server' => $serverCount,
|
||||||
'local' => $localCount,
|
'local' => $localCount,
|
||||||
'to_download' => $toDownload,
|
'to_download' => $toDownload,
|
||||||
@@ -193,7 +193,7 @@ class UpdateCoreAction
|
|||||||
file_put_contents($targetDir . '/' . $name, $content);
|
file_put_contents($targetDir . '/' . $name, $content);
|
||||||
$synced++;
|
$synced++;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('Vikon FM: sub download failed', ['identity' => $identity, 'error' => $e->getMessage()]);
|
Log::channel('vikon')->warning('Vikon FM: sub download failed', ['identity' => $identity, 'error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $synced;
|
return $synced;
|
||||||
@@ -236,7 +236,7 @@ class UpdateCoreAction
|
|||||||
|
|
||||||
$synced++;
|
$synced++;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('Vikon FM: new file failed', ['identity' => $identity, 'error' => $e->getMessage()]);
|
Log::channel('vikon')->warning('Vikon FM: new file failed', ['identity' => $identity, 'error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $synced;
|
return $synced;
|
||||||
@@ -333,7 +333,7 @@ class UpdateCoreAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($removed > 0) {
|
if ($removed > 0) {
|
||||||
Log::info('Vikon: cleaned up post-sync', ['removed' => $removed]);
|
Log::channel('vikon')->info('Vikon: cleaned up post-sync', ['removed' => $removed]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,10 +346,10 @@ class UpdateCoreAction
|
|||||||
|
|
||||||
if ($latestVersion) {
|
if ($latestVersion) {
|
||||||
cache()->put('vikon:current_version', $latestVersion, 3600);
|
cache()->put('vikon:current_version', $latestVersion, 3600);
|
||||||
Log::info('Vikon: version updated', ['version' => $latestVersion]);
|
Log::channel('vikon')->info('Vikon: version updated', ['version' => $latestVersion]);
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('Vikon: failed to update version', ['error' => $e->getMessage()]);
|
Log::channel('vikon')->warning('Vikon: failed to update version', ['error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class UpdatePartAction
|
|||||||
{
|
{
|
||||||
$config = $this->modulesConfig[$moduleId] ?? throw new \RuntimeException("Неизвестный модуль: {$moduleId}");
|
$config = $this->modulesConfig[$moduleId] ?? throw new \RuntimeException("Неизвестный модуль: {$moduleId}");
|
||||||
|
|
||||||
Log::info('Vikon: starting part update', ['module' => $moduleId, 'part' => $part]);
|
Log::channel('vikon')->info('Vikon: starting part update', ['module' => $moduleId, 'part' => $part]);
|
||||||
|
|
||||||
// Step 1: Request generation
|
// Step 1: Request generation
|
||||||
$genResponse = $this->http->postWithToken(
|
$genResponse = $this->http->postWithToken(
|
||||||
@@ -40,7 +40,7 @@ class UpdatePartAction
|
|||||||
|
|
||||||
$operationIdentity = $genBody['operation_identity'];
|
$operationIdentity = $genBody['operation_identity'];
|
||||||
|
|
||||||
Log::info('Vikon: part generation requested', ['operation' => $operationIdentity]);
|
Log::channel('vikon')->info('Vikon: part generation requested', ['operation' => $operationIdentity]);
|
||||||
|
|
||||||
// Step 2: Poll status
|
// Step 2: Poll status
|
||||||
$pollResult = $this->pollStatus->run($operationIdentity, $accessToken);
|
$pollResult = $this->pollStatus->run($operationIdentity, $accessToken);
|
||||||
@@ -98,7 +98,7 @@ class UpdatePartAction
|
|||||||
$this->cleanupPostSync($modulePath);
|
$this->cleanupPostSync($modulePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info('Vikon: part update complete', ['module' => $moduleId, 'part' => $part, 'synced' => $syncedCount]);
|
Log::channel('vikon')->info('Vikon: part update complete', ['module' => $moduleId, 'part' => $part, 'synced' => $syncedCount]);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'success' => true,
|
'success' => true,
|
||||||
@@ -222,7 +222,7 @@ class UpdatePartAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($removed > 0) {
|
if ($removed > 0) {
|
||||||
Log::info('Vikon: cleaned up post-sync', ['removed' => $removed, 'path' => $modulePath]);
|
Log::channel('vikon')->info('Vikon: cleaned up post-sync', ['removed' => $removed, 'path' => $modulePath]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class FilesystemTask
|
|||||||
public function safeRemove(string $path, string $base, bool $recursive = false): bool
|
public function safeRemove(string $path, string $base, bool $recursive = false): bool
|
||||||
{
|
{
|
||||||
if (!$this->isPathSafe($path, $base)) {
|
if (!$this->isPathSafe($path, $base)) {
|
||||||
Log::warning('Path traversal blocked', ['path' => $path, 'base' => $base]);
|
Log::channel('vikon')->warning('Path traversal blocked', ['path' => $path, 'base' => $base]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!file_exists($path)) return true;
|
if (!file_exists($path)) return true;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class PollPartStatusTask
|
|||||||
$body = $response->json();
|
$body = $response->json();
|
||||||
$status = $body['status'] ?? -2;
|
$status = $body['status'] ?? -2;
|
||||||
|
|
||||||
Log::info('Vikon poll part status', [
|
Log::channel('vikon')->info('Vikon poll part status', [
|
||||||
'operation' => $operationIdentity,
|
'operation' => $operationIdentity,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'attempt' => $attempt + 1,
|
'attempt' => $attempt + 1,
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class ValidateTokenTask
|
|||||||
|
|
||||||
return $valid;
|
return $valid;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('Vikon token validation failed', ['error' => $e->getMessage()]);
|
Log::channel('vikon')->warning('Vikon token validation failed', ['error' => $e->getMessage()]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class VikonController extends Controller
|
|||||||
$expectedState = Session::pull('oauth_state');
|
$expectedState = Session::pull('oauth_state');
|
||||||
|
|
||||||
if ($state && $expectedState && $state !== $expectedState) {
|
if ($state && $expectedState && $state !== $expectedState) {
|
||||||
Log::warning('Vikon OAuth CSRF mismatch');
|
Log::channel('vikon')->warning('Vikon OAuth CSRF mismatch');
|
||||||
}
|
}
|
||||||
|
|
||||||
$code = $request->query('code');
|
$code = $request->query('code');
|
||||||
@@ -70,7 +70,7 @@ class VikonController extends Controller
|
|||||||
Session::put('vikon_access_token', $tokens['access_token']);
|
Session::put('vikon_access_token', $tokens['access_token']);
|
||||||
Session::put('vikon_refresh_token', $tokens['refresh_token']);
|
Session::put('vikon_refresh_token', $tokens['refresh_token']);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('OAuth callback failed', ['error' => $e->getMessage()]);
|
Log::channel('vikon')->error('OAuth callback failed', ['error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ class VikonController extends Controller
|
|||||||
$message = $this->updateCore->run($request->validated('module_id'), $token);
|
$message = $this->updateCore->run($request->validated('module_id'), $token);
|
||||||
return response()->json(['success' => true, 'message' => $message]);
|
return response()->json(['success' => true, 'message' => $message]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('Vikon update failed', ['error' => $e->getMessage()]);
|
Log::channel('vikon')->error('Vikon update failed', ['error' => $e->getMessage()]);
|
||||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ class VikonController extends Controller
|
|||||||
$message = $this->syncFiles->run($request->validated('module_id'), $token);
|
$message = $this->syncFiles->run($request->validated('module_id'), $token);
|
||||||
return response()->json(['success' => true, 'message' => $message]);
|
return response()->json(['success' => true, 'message' => $message]);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('Vikon sync failed', ['error' => $e->getMessage()]);
|
Log::channel('vikon')->error('Vikon sync failed', ['error' => $e->getMessage()]);
|
||||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ class VikonController extends Controller
|
|||||||
);
|
);
|
||||||
return response()->json($result);
|
return response()->json($result);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('Vikon part update failed', ['error' => $e->getMessage()]);
|
Log::channel('vikon')->error('Vikon part update failed', ['error' => $e->getMessage()]);
|
||||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class VikonTokenRefresh
|
|||||||
Session::put('vikon_access_token', $tokens['access_token']);
|
Session::put('vikon_access_token', $tokens['access_token']);
|
||||||
Session::put('vikon_refresh_token', $tokens['refresh_token']);
|
Session::put('vikon_refresh_token', $tokens['refresh_token']);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::warning('Vikon auto-refresh failed', ['error' => $e->getMessage()]);
|
Log::channel('vikon')->warning('Vikon auto-refresh failed', ['error' => $e->getMessage()]);
|
||||||
Session::forget(['vikon_access_token', 'vikon_refresh_token']);
|
Session::forget(['vikon_access_token', 'vikon_refresh_token']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user