-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlogValheim.ps1
69 lines (62 loc) · 1.67 KB
/
logValheim.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
param(
[String]$LogPath
)
if (-Not $LogPath)
{
Write-Host "Path is not specified." -ForegroundColor Red
return
}
if (-Not (Test-Path $LogPath))
{
Write-Host "File not found: $LogPath" -ForegroundColor Yellow
return
}
function Get-LogColor
{
Param(
[Parameter(Position = 0)]
[String]$LogEntry
)
process {
if ($LogEntry.Contains("ValheimRAFT") -or $LogEntry.Contains("ValheimVehicles") -or $LogEntry.Contains("DynamicLocations") -or $LogEntry.Contains("ZdoWatcher"))
{
if ( $LogEntry.Contains("Debug"))
{
Return "Green"
}
elseif ($LogEntry.Contains("Warn"))
{
Return "Yellow"
}
elseif ($LogEntry.Contains("Error") -or $LogEntry.Contains("NullReferenceException"))
{
Return "Red"
}
else
{
Return "White"
}
}
# we should still see red for errors.
if ($LogEntry.Contains("NullReferenceException") -or $LogEntry.Contains("Error"))
{
Return "Red"
}
else
{
# makes other messages less visible
Return "Gray"
}
}
}
# Define patterns to exclude
$excludePatterns = @(".*Activating default element Continue")
# Tail the log file and apply filtering only
gc -wait -tail 10 $LogPath |
Where-Object {
# Check if the line matches any exclusion pattern
$_ -notmatch $excludePatterns
} |
ForEach-Object {
Write-Host -ForegroundColor (Get-LogColor $_) $_
}