Python根记录器两次输出

时间:2019-01-16 10:52:36

标签: python logging

在我的一个模块中,logger输出两次。我使用在其他模块中正常工作的root记录器sql_logger('SQL', log_1)sys_logger('SYS, log_2)

propagate无效

  def __init__(self):
    self.xls_sys_l = root_logger("XLS", sys_log)
    self.xls_sys_l.propagate = 0
    self.xls_l = root_logger("Excel", xls_log)
    self.xls_l.propagate = 0

   def format(self)
           for col in ws.iter_cols():
            for cell in col:
                if (cell.value == 'value1'):
                    carPlate_col = cell.column
                    for row in 
           ws.iter_rows(min_col=column_index_from_string(carPlate_col),

        max_col=column_index_from_string(carPlate_col),
                                            min_row=3):
                        for cell in row:
                            carPlate_row = cell.row
                            carPlate_val = cell.value

                            '''FORMAT car plate values'''
                            # translate cyrillic symbols to latin
                            carPlate_val_tr = car_plate_translate(str(carPlate_val))
                            # Check car plate number and write errors:
                            # 1. if length is not between 7 and 9 symbols
                            # 2. if wrong symbols were used

                            if not (carPlate_val == None):
                                carPlate_checked = car_plate_check(str(carPlate_val))
                                # non-valid, wrong length

                                if carPlate_checked == 1:
                                    self.xls_l.warning('Error 1')
                                elif carPlate_checked == 2:
                                    self.xls_l.warning('Error 2')

这不是因为循环。 print(carPlate_checked, cell.coordinate)每次迭代仅输出1个字符串。

0 个答案:

没有答案