(self, logName)
| 271 | self.printTree(node.childD[child], dep + 1) |
| 272 | |
| 273 | def parse(self, logName): |
| 274 | print("Parsing file: " + os.path.join(self.path, logName)) |
| 275 | start_time = datetime.now() |
| 276 | self.logName = logName |
| 277 | rootNode = Node() |
| 278 | logCluL = [] |
| 279 | |
| 280 | self.load_data() |
| 281 | |
| 282 | count = 0 |
| 283 | for idx, line in self.df_log.iterrows(): |
| 284 | logID = line["LineId"] |
| 285 | logmessageL = self.preprocess(line["Content"]).strip().split() |
| 286 | matchCluster = self.treeSearch(rootNode, logmessageL) |
| 287 | |
| 288 | # Match no existing log cluster |
| 289 | if matchCluster is None: |
| 290 | newCluster = Logcluster(logTemplate=logmessageL, logIDL=[logID]) |
| 291 | logCluL.append(newCluster) |
| 292 | self.addSeqToPrefixTree(rootNode, newCluster) |
| 293 | |
| 294 | # Add the new log message to the existing cluster |
| 295 | else: |
| 296 | newTemplate = self.getTemplate(logmessageL, matchCluster.logTemplate) |
| 297 | matchCluster.logIDL.append(logID) |
| 298 | if " ".join(newTemplate) != " ".join(matchCluster.logTemplate): |
| 299 | matchCluster.logTemplate = newTemplate |
| 300 | |
| 301 | count += 1 |
| 302 | if count % 1000 == 0 or count == len(self.df_log): |
| 303 | print( |
| 304 | "Processed {0:.1f}% of log lines.".format( |
| 305 | count * 100.0 / len(self.df_log) |
| 306 | ) |
| 307 | ) |
| 308 | |
| 309 | if not os.path.exists(self.savePath): |
| 310 | os.makedirs(self.savePath) |
| 311 | |
| 312 | self.outputResult(logCluL) |
| 313 | |
| 314 | print("Parsing done. [Time taken: {!s}]".format(datetime.now() - start_time)) |
| 315 | |
| 316 | def load_data(self): |
| 317 | headers, regex = self.generate_logformat_regex(self.log_format) |
no test coverage detected