-
Notifications
You must be signed in to change notification settings - Fork 34
/
loganalyzer.py
executable file
·221 lines (196 loc) · 7.35 KB
/
loganalyzer.py
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/usr/bin/env python3
import argparse
import textwrap
from checks.vars import *
from checks.core import *
from checks.audio import *
from checks.encoding import *
from checks.graphics import *
from checks.macos import *
from checks.network import *
from checks.plugins import *
from checks.sources import *
from checks.wayland import *
from checks.windows import *
from checks.utils.fetchers import *
from checks.utils.utils import *
from checks.utils.windowsversions import *
# main functions
##############################################
def textOutput(string):
dedented_text = textwrap.dedent(string).strip()
return textwrap.fill(dedented_text, initial_indent=' ' * 4, subsequent_indent=' ' * 4, width=80, )
def getSummary(messages):
summary = ""
critical = []
warning = []
info = []
for i in messages:
if (i[0] == LEVEL_CRITICAL):
critical.append(i[1])
elif (i[0] == LEVEL_WARNING):
warning.append(i[1])
elif (i[0] == LEVEL_INFO):
info.append(i[1])
summary += "{}Critical: {}\n".format(RED, ", ".join(critical))
summary += "{}Warning: {}\n".format(YELLOW, ", ".join(warning))
summary += "{}Info: {}\n".format(CYAN, ", ".join(info))
return summary
def getResults(messages):
results = ""
results += "{}--------------------------------------\n".format(RESET)
results += " \n"
results += "Details\n"
results += "\nCritical:"
for i in messages:
if (i[0] == 3):
results += "\n{}{}\n".format(RED, i[1])
results += textOutput(i[2])
results += "{} \n".format(RESET)
results += "\nWarning:"
for i in messages:
if (i[0] == 2):
results += "\n{}{}\n".format(YELLOW, i[1])
results += textOutput(i[2])
results += "{} \n".format(RESET)
results += "\nInfo:"
for i in messages:
if (i[0] == 1):
results += "\n{}{}\n".format(CYAN, i[1])
results += textOutput(i[2])
results += "{} \n".format(RESET)
return results
def doAnalysis(url=None, filename=None):
messages = []
success = False
logLines = []
if url is not None:
gist = matchGist(url)
haste = matchHaste(url)
obs = matchObs(url)
pastebin = matchPastebin(url)
discord = matchDiscord(url)
if (gist):
gistObject = getGist(gist.groups()[-1])
logLines = getLinesGist(gistObject)
messages.append(getDescriptionGist(gistObject))
success = True
elif (haste):
hasteObject = getHaste(haste.groups()[-1])
logLines = getLinesHaste(hasteObject)
messages.append(getDescription(logLines))
success = True
elif (obs):
obslogObject = getObslog(obs.groups()[-1])
logLines = getLinesObslog(obslogObject)
messages.append(getDescription(logLines))
success = True
elif (pastebin):
pasteObject = getRawPaste(pastebin.groups()[-1])
logLines = getLinesPaste(pasteObject)
messages.append(getDescription(logLines))
success = True
elif (discord):
attachment = discord.groups()[-1]
if attachment == "message":
attachment = discord.groups()[-2]
pasteObject = getRawDiscord(attachment)
if len(pasteObject) > 0:
logLines = getLinesDiscord(pasteObject)
messages.append(getDescription(logLines))
success = True
elif filename is not None:
logLines = getLinesLocal(filename)
messages.append(getDescription(logLines))
success = True
if (success):
classic, m = checkClassic(logLines)
crash, m = checkCrash(logLines)
messages.append(m)
if (not classic and not crash):
messages.extend([
checkObsVersion(logLines),
checkDual(logLines),
checkAutoconfig(logLines),
checkCPU(logLines),
checkAMDdrivers(logLines),
checkNVIDIAdrivers(logLines),
checkGPU(logLines),
checkRefreshes(logLines),
checkInit(logLines),
checkWayland(logLines),
checkNVIDIAdriversEGL(logLines),
checkNVENC(logLines),
check940(logLines),
checkKiller(logLines),
checkWifi(logLines),
checkBind(logLines),
checkWindowsVer(logLines),
checkWindowsARM64(logLines),
checkMacVer(logLines),
checkAdmin(logLines),
checkImports(logLines),
check32bitOn64bit(logLines),
checkWindowsARM64EmulationStatus(logLines),
checkRosettaTranslationStatus(logLines),
checkAttempt(logLines),
checkMP4(logLines),
checkPreset(logLines),
checkCustom(logLines),
checkBrowserAccel(logLines),
checkAudioBuffering(logLines),
checkDrop(logLines),
checkRenderLag(logLines),
checkEncodeError(logLines),
checkEncoding(logLines),
checkMulti(logLines),
checkStreamSettingsX264(logLines),
checkStreamSettingsNVENC(logLines),
checkMicrosoftSoftwareGPU(logLines),
checkWasapiSamples(logLines),
checkOpenGLonWindows(logLines),
checkGameDVR(logLines),
checkGameMode(logLines),
checkWin10Hags(logLines),
checkNICSpeed(logLines),
checkDynamicBitrate(logLines),
checkNetworkOptimizations(logLines),
checkTCPPacing(logLines),
checkStreamDelay(logLines),
checkUnknownEncoder(logLines),
checkBrowserSource(logLines),
checkMonitoringDevice(logLines),
checkPluginList(logLines),
checkVantage(logLines),
checkPortableMode(logLines),
checkSafeMode(logLines),
checkSnapPackage(logLines),
checkMacPermissions(logLines)
])
messages.extend(checkVideoSettings(logLines))
m = parseScenes(logLines)
# TODO Verify .extend() can be used for parseScenes
for sublist in m:
if sublist is not None:
for item in sublist:
messages.append(item)
else:
messages.append([LEVEL_CRITICAL, "NO LOG",
"URL or file doesn't contain a log."])
# print(messages)
ret = [i for i in messages if i is not None]
# print(ret)
return (ret)
def main():
parser = argparse.ArgumentParser()
loggroup = parser.add_mutually_exclusive_group(required=True)
loggroup.add_argument("--url", '-u', dest='url',
default=None, help="url of gist or haste with log")
loggroup.add_argument("--file", "-f", dest='file',
default=None, help="local filenamne with log")
flags = parser.parse_args()
msgs = doAnalysis(url=flags.url, filename=flags.file)
print(getSummary(msgs))
print(getResults(msgs))
if __name__ == "__main__":
main()