param( [string]$ProjectRoot = (Resolve-Path "$PSScriptRoot\..").Path, [string]$AdbPath = "C:\android\platform-tools\adb.exe", [string]$PackageName = "anywheresoftware.b4a.swarm", [switch]$KeepExisting ) $ErrorActionPreference = "Stop" if (-not (Test-Path -LiteralPath $AdbPath)) { throw "adb.exe non trovato: $AdbPath" } $logDir = Join-Path $ProjectRoot "logs" New-Item -ItemType Directory -Force -Path $logDir | Out-Null $stamp = Get-Date -Format "yyyyMMdd-HHmmss" $logFile = Join-Path $logDir "logcat-$stamp.txt" & $AdbPath wait-for-device if (-not $KeepExisting) { & $AdbPath logcat -c } Write-Host "Logcat live. Premi Ctrl+C per fermare." Write-Host "File: $logFile" Write-Host "Filtro mentale utile: cerca '$PackageName', 'AndroidRuntime', 'FATAL EXCEPTION', 'System.err', 'B4A'." Write-Host "" & $AdbPath logcat -v time | Tee-Object -FilePath $logFile