Avoid repeating the same warning.
Also report a warnings count.
This commit is contained in:
parent
6b21f00a65
commit
f38b63236d
|
|
@ -315,8 +315,10 @@ def main():
|
|||
GS.set_sch(solve_schematic(args.schematic, args.board_file))
|
||||
# Determine the PCB file
|
||||
GS.set_pcb(solve_board_file(GS.sch_file, args.board_file))
|
||||
|
||||
# Do all the job (pre-flight + outputs)
|
||||
generate_outputs(outputs, args.target, args.invert_sel, args.skip_pre)
|
||||
# Print total warnings
|
||||
logger.log_totals()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
22
kibot/log.py
22
kibot/log.py
|
|
@ -30,10 +30,30 @@ def set_domain(name):
|
|||
domain = name
|
||||
|
||||
|
||||
class MyLogger(logging.Logger):
|
||||
warn_hash = {}
|
||||
warn_tcnt = warn_cnt = 0
|
||||
|
||||
def warning(self, msg, *args, **kwargs):
|
||||
MyLogger.warn_tcnt += 1
|
||||
if msg in MyLogger.warn_hash:
|
||||
MyLogger.warn_hash[msg] += 1
|
||||
return
|
||||
MyLogger.warn_cnt += 1
|
||||
MyLogger.warn_hash[msg] = 1
|
||||
super().warning(msg, *args, **kwargs)
|
||||
|
||||
def log_totals(self):
|
||||
if MyLogger.warn_cnt:
|
||||
self.info('Found {} unique warning/s ({} total)'.format(MyLogger.warn_cnt, MyLogger.warn_tcnt))
|
||||
|
||||
|
||||
def init(verbose, quiet):
|
||||
"""Initialize the logging feature using a custom format and the specified
|
||||
verbosity level"""
|
||||
|
||||
# Use a class to count and filter warnings
|
||||
logging.setLoggerClass(MyLogger)
|
||||
# Choose the log level
|
||||
log_level = logging.INFO
|
||||
if verbose:
|
||||
log_level = logging.DEBUG
|
||||
|
|
|
|||
Loading…
Reference in New Issue