forked from Tatenshi/RecentlyPlayed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-logging.ps1
76 lines (61 loc) · 2.01 KB
/
start-logging.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
70
71
72
73
74
75
76
Param(
[Parameter(Mandatory=$false)]
[Switch] $self,
[Parameter(Mandatory=$false)]
[Switch] $all,
[Parameter(Mandatory=$false)]
[String] $custom="",
[Parameter(Mandatory=$false)]
[String] $file="",
[Parameter(Mandatory=$false)]
[Switch] $help,
[Parameter(Mandatory=$false)]
[Switch] $excludeHeader
)
if ($help -eq $true) {
if ($excludeHeader -eq $false) {
Write-Output "`"Start-Logging`" - Logs Beat Saber using `"adb logcat`""
Write-Output "`n-- Arguments --`n"
}
Write-Output "-Self `t`t Only Logs your mod and Crashes"
Write-Output "-All `t`t Logs everything, including logs made by the Quest itself"
Write-Output "-Custom `t Specify a specific logging pattern, e.g `"custom-types|questui`""
Write-Output "`t`t NOTE: The paterent `"AndriodRuntime|CRASH`" is always appended to a custom pattern"
Write-Output "-File `t`t Saves the output of the log to the file name given"
exit
}
$bspid = adb shell pidof com.beatgames.beatsaber
$command = "adb logcat "
if ($all -eq $false) {
$loops = 0
while ([string]::IsNullOrEmpty($bspid) -and $loops -lt 3) {
Start-Sleep -Milliseconds 100
$bspid = adb shell pidof com.beatgames.beatsaber
$loops += 1
}
if ([string]::IsNullOrEmpty($bspid)) {
Write-Output "Could not connect to adb, exiting..."
exit 1
}
$command += "--pid $bspid"
}
if ($all -eq $false) {
$pattern = "("
if ($self -eq $true) {
$modID = (Get-Content "./mod.json" -Raw | ConvertFrom-Json).id
$pattern += "$modID|"
}
if (![string]::IsNullOrEmpty($custom)) {
$pattern += "$custom|"
}
if ($pattern -eq "(") {
$pattern = "(QuestHook|modloader|"
}
$pattern += "AndroidRuntime|CRASH)"
$command += " | Select-String -pattern `"$pattern`""
}
if (![string]::IsNullOrEmpty($file)) {
$command += " | Out-File -FilePath $PSScriptRoot\$file"
}
Write-Output "Logging using Command `"$command`""
Invoke-Expression $command