(self, para)
如果没匹配上，会生成0, 原始代码
如果没匹配上，会生成0, 原始代码
如果没匹配上，会生成0 原始代码
def matchLogsFromFile(self, para):
        '''
         如果没匹配上，会生成0, 原始代码
        '''
        #print('#######################################')
        if para['plot_flag'] == 1:
            #print('#######################################')
            self.drawTree() #画ft-tree


        raw_log_path = para['runtime_log_path']
        out_seq_path = para['out_seq_path']
        short_threshold = para['short_threshold']
        template_path = para['template_path']
        match_model = para['match_model']

        f = open(out_seq_path, 'w')
        short_log = 0
        # short_threshold = 5
        count_zero = 0
        total_num = 0
        with open(raw_log_path) as IN:
            for line in IN:
                total_num += 1
                timestamp = line.strip().split()[0]
                log_words = ft_tree.getMsgFromNewSyslog(line)[1]

                tag,cur_match = self.match(log_words, match_model)
                if len(log_words) < short_threshold:  # 过滤长度小于5的日志
                    short_log += 1
                    tag = -1

                # 匹配到了输出1~n，没匹配到输出0，日志小于过滤长度输出-1
                #输出时间戳
                # f.writelines(timestamp + ' ' + str(tag) + '\n')
                f.writelines(str(tag) + '\n')
                if tag == 0:
                    count_zero += 1
                    # print line



        print('filting # short logs:', short_log, '| threshold =', short_threshold)
        print('# of unmatched log (except filting):', count_zero)
        print('# of total logs:', total_num)
        print('seq_file_path:', out_seq_path)
def matchLogsFromFile ( self , para ) : #print('#######################################') if para [ 'plot_flag' ] == 1 : #print('#######################################') self . drawTree ( ) #画ft-tree raw_log_path = para [ 'runtime_log_path' ] out_seq_path = para [ 'out_seq_path' ] short_threshold = para [ 'short_threshold' ] template_path = para [ 'template_path' ] match_model = para [ 'match_model' ] f = open ( out_seq_path , 'w' ) short_log = 0 # short_threshold = 5 count_zero = 0 total_num = 0 with open ( raw_log_path ) as IN : for line in IN : total_num += 1 timestamp = line . strip ( ) . split ( ) [ 0 ] log_words = ft_tree . getMsgFromNewSyslog ( line ) [ 1 ] tag , cur_match = self . match ( log_words , match_model ) if len ( log_words ) < short_threshold : # 过滤长度小于5的日志 short_log += 1 tag = - 1 # 匹配到了输出1~n，没匹配到输出0，日志小于过滤长度输出-1 #输出时间戳 # f.writelines(timestamp + ' ' + str(tag) + '\n') f . writelines ( str ( tag ) + '\n' ) if tag == 0 : count_zero += 1 # print line print ( 'filting # short logs:' , short_log , '| threshold =' , short_threshold ) print ( '# of unmatched log (except filting):' , count_zero ) print ( '# of total logs:' , total_num ) print ( 'seq_file_path:' , out_seq_path )