Improves log reading and build diagnostics
nearly a month ago
This commit is contained in:
@@ -628,29 +628,40 @@ Write-Host ""Controller process: $controllerProcessInfo""
|
||||
Write-Host ""`n=== Recent Log Entries (last 30 lines) ==="" -ForegroundColor Cyan
|
||||
if (Test-Path $logPath) {{
|
||||
try {{
|
||||
$logFileInfo = Get-Item $logPath -ErrorAction SilentlyContinue
|
||||
if ($logFileInfo) {{
|
||||
Write-Host ""Log file size: $($logFileInfo.Length) bytes"" -ForegroundColor Gray
|
||||
}}
|
||||
$logFileInfo = Get-Item $logPath -ErrorAction Stop
|
||||
$fileSize = $logFileInfo.Length
|
||||
Write-Host ""Log file size: $fileSize bytes"" -ForegroundColor Gray
|
||||
|
||||
$logContent = Get-Content $logPath -ErrorAction SilentlyContinue
|
||||
if ($logContent) {{
|
||||
$logLines = if ($logContent.Count -gt 30) {{ $logContent[-30..-1] }} else {{ $logContent }}
|
||||
Write-Host ""Found $($logLines.Count) log lines (showing last $([Math]::Min(30, $logLines.Count)))""
|
||||
$logLines | ForEach-Object {{ Write-Host $_ }}
|
||||
if ($fileSize -eq 0) {{
|
||||
Write-Host ""Log file is empty (0 bytes) - controller may not have started writing yet"" -ForegroundColor Yellow
|
||||
}} else {{
|
||||
Write-Host ""Log file exists but appears to be empty or unreadable"" -ForegroundColor Yellow
|
||||
Write-Host ""Attempting to read raw bytes..."" -ForegroundColor Gray
|
||||
try {{
|
||||
$rawBytes = [IO.File]::ReadAllBytes($logPath)
|
||||
Write-Host ""Log file contains $($rawBytes.Length) bytes""
|
||||
if ($rawBytes.Length -gt 0) {{
|
||||
$text = [System.Text.Encoding]::UTF8.GetString($rawBytes)
|
||||
Write-Host ""Log content (first 500 chars):"" -ForegroundColor Cyan
|
||||
Write-Host $text.Substring(0, [Math]::Min(500, $text.Length))
|
||||
# Try Get-Content first
|
||||
$logContent = Get-Content $logPath -ErrorAction SilentlyContinue
|
||||
if ($null -ne $logContent -and $logContent.Count -gt 0) {{
|
||||
$logLines = if ($logContent.Count -gt 30) {{ $logContent[-30..-1] }} else {{ $logContent }}
|
||||
Write-Host ""Found $($logLines.Count) log lines (showing last $([Math]::Min(30, $logLines.Count)))""
|
||||
foreach ($line in $logLines) {{
|
||||
Write-Host $line
|
||||
}}
|
||||
}} else {{
|
||||
Write-Host ""Get-Content returned no lines, attempting to read raw bytes..."" -ForegroundColor Yellow
|
||||
try {{
|
||||
$rawBytes = [IO.File]::ReadAllBytes($logPath)
|
||||
Write-Host ""Read $($rawBytes.Length) bytes from log file""
|
||||
if ($rawBytes.Length -gt 0) {{
|
||||
$text = [System.Text.Encoding]::UTF8.GetString($rawBytes)
|
||||
$lines = $text -split ""`r?`n""
|
||||
Write-Host ""Parsed into $($lines.Count) lines""
|
||||
$displayLines = if ($lines.Count -gt 30) {{ $lines[-30..-1] }} else {{ $lines }}
|
||||
foreach ($line in $displayLines) {{
|
||||
if ($line) {{ Write-Host $line }}
|
||||
}}
|
||||
}} else {{
|
||||
Write-Host ""Log file is empty"" -ForegroundColor Yellow
|
||||
}}
|
||||
}} catch {{
|
||||
Write-Host ""Could not read log file bytes: $($_.Exception.Message)"" -ForegroundColor Red
|
||||
}}
|
||||
}} catch {{
|
||||
Write-Host ""Could not read log file bytes: $($_.Exception.Message)"" -ForegroundColor Red
|
||||
}}
|
||||
}}
|
||||
}} catch {{
|
||||
|
||||
Reference in New Issue
Block a user