(self, logname)
| 248 | self.printTree(node.childD[child], dep + 1) |
| 249 | |
| 250 | def parse(self, logname): |
| 251 | starttime = datetime.now() |
| 252 | print("Parsing file: " + os.path.join(self.path, logname)) |
| 253 | self.logname = logname |
| 254 | self.load_data() |
| 255 | rootNode = Node() |
| 256 | logCluL = [] |
| 257 | |
| 258 | count = 0 |
| 259 | for idx, line in self.df_log.iterrows(): |
| 260 | logID = line["LineId"] |
| 261 | logmessageL = list( |
| 262 | filter( |
| 263 | lambda x: x != "", |
| 264 | re.split(r"[\s=:,]", self.preprocess(line["Content"])), |
| 265 | ) |
| 266 | ) |
| 267 | constLogMessL = [w for w in logmessageL if w != "<*>"] |
| 268 | |
| 269 | # Find an existing matched log cluster |
| 270 | matchCluster = self.PrefixTreeMatch(rootNode, constLogMessL, 0) |
| 271 | |
| 272 | if matchCluster is None: |
| 273 | matchCluster = self.SimpleLoopMatch(logCluL, constLogMessL) |
| 274 | |
| 275 | if matchCluster is None: |
| 276 | matchCluster = self.LCSMatch(logCluL, logmessageL) |
| 277 | |
| 278 | # Match no existing log cluster |
| 279 | if matchCluster is None: |
| 280 | newCluster = LCSObject(logTemplate=logmessageL, logIDL=[logID]) |
| 281 | logCluL.append(newCluster) |
| 282 | self.addSeqToPrefixTree(rootNode, newCluster) |
| 283 | # Add the new log message to the existing cluster |
| 284 | else: |
| 285 | newTemplate = self.getTemplate( |
| 286 | self.LCS(logmessageL, matchCluster.logTemplate), |
| 287 | matchCluster.logTemplate, |
| 288 | ) |
| 289 | if " ".join(newTemplate) != " ".join(matchCluster.logTemplate): |
| 290 | self.removeSeqFromPrefixTree(rootNode, matchCluster) |
| 291 | matchCluster.logTemplate = newTemplate |
| 292 | self.addSeqToPrefixTree(rootNode, matchCluster) |
| 293 | if matchCluster: |
| 294 | matchCluster.logIDL.append(logID) |
| 295 | count += 1 |
| 296 | if count % 1000 == 0 or count == len(self.df_log): |
| 297 | print( |
| 298 | "Processed {0:.1f}% of log lines.".format( |
| 299 | count * 100.0 / len(self.df_log) |
| 300 | ) |
| 301 | ) |
| 302 | |
| 303 | if not os.path.exists(self.savePath): |
| 304 | os.makedirs(self.savePath) |
| 305 | |
| 306 | self.outputResult(logCluL) |
| 307 | print("Parsing done. [Time taken: {!s}]".format(datetime.now() - starttime)) |
no test coverage detected