WMS_MAIN/get_specific_logs.ps1
liufumingren 8cf2c5befa 1
2026-05-20 16:31:29 +08:00

35 lines
1.1 KiB
PowerShell

$targetTs = "2026-05-20 02:20:00"
$kws = @(
'print-retry-compensation',
'print_retry_compensation\.js',
'retryFailed',
'触发补打',
'任务执行完成',
'/__schedule\?path=D:\\wms\\app\\schedule\\print_retry_compensation\.js'
)
$results = New-Object System.Collections.Generic.List[string]
Get-ChildItem logs/wms/wms-web.log* | ForEach-Object {
$fileName = $_.Name
$fs = New-Object System.IO.FileStream($_.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::ReadWrite)
$reader = New-Object System.IO.StreamReader($fs)
while($null -ne ($line = $reader.ReadLine())){
if($line -match '^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})'){
$ts = $matches[1]
if($ts -ge $targetTs){
foreach($k in $kws){
if($line -match $k){
$results.Add("$($fileName): $($line)")
break
}
}
}
}
}
$reader.Close()
$fs.Dispose()
}
$results | ForEach-Object { Write-Output $_ }