Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions diagnostics/rolling-wsl-logs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
param (
[int] $PeriodSeconds = 3600,
[ValidateNotNullOrEmpty()]
[string] $Profile = (Join-Path $PSScriptRoot "wsl.wprp")
)

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

trap
{
try { & wpr.exe -cancel | Out-Null } catch {}
throw
}

[console]::TreatControlCAsInput = $true
Comment thread
OneBlue marked this conversation as resolved.


Write-Host "Press any key to exit"

$running = $true
while($running)
{
& wpr.exe -start $Profile -filemode
$rotation = (Get-Date).AddSeconds($PeriodSeconds)

while($rotation -Gt (Get-Date))
{
if ($Host.UI.RawUI.KeyAvailable)
{
$keyPressed = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyUp, IncludeKeyDown")
if ($keyPressed.KeyDown -eq "True")
{
$running = $false
Write-Host "Exiting"
break
}
}

[Threading.Thread]::Sleep(1000)
}

$file = Get-Date ($rotation.ToUniversalTime()) -UFormat '%Y-%m-%d %H-%M-%S'
$file += ".etl"
Write-Host Writing logs to $file
& wpr.exe -stop $file
Comment thread
OneBlue marked this conversation as resolved.
}