From 6a885632e8e21a73e4e989bac48d48bf58f928d4 Mon Sep 17 00:00:00 2001 From: zhoujun Date: Mon, 21 Mar 2022 23:48:50 -0500 Subject: [PATCH] fix log print twice error (#5743) --- ppocr/utils/logging.py | 3 ++- test_tipc/supplementary/config.py | 2 +- tools/infer_vqa_token_ser_re.py | 2 +- tools/program.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ppocr/utils/logging.py b/ppocr/utils/logging.py index ce827e8b..1eac8f35 100644 --- a/ppocr/utils/logging.py +++ b/ppocr/utils/logging.py @@ -26,7 +26,7 @@ logger_initialized = {} @functools.lru_cache() -def get_logger(name='root', log_file=None, log_level=logging.DEBUG): +def get_logger(name='ppocr', log_file=None, log_level=logging.DEBUG): """Initialize and get a logger by name. If the logger has not been initialized, this method will initialize the logger by adding one or two handlers, otherwise the initialized logger will @@ -67,4 +67,5 @@ def get_logger(name='root', log_file=None, log_level=logging.DEBUG): else: logger.setLevel(logging.ERROR) logger_initialized[name] = True + logger.propagate = False return logger diff --git a/test_tipc/supplementary/config.py b/test_tipc/supplementary/config.py index d0dce227..72a99c70 100644 --- a/test_tipc/supplementary/config.py +++ b/test_tipc/supplementary/config.py @@ -122,7 +122,7 @@ def preprocess(is_train=False): log_file = '{}/train.log'.format(save_model_dir) else: log_file = None - logger = get_logger(name='root', log_file=log_file) + logger = get_logger(log_file=log_file) # check if set use_gpu=True in paddlepaddle cpu version use_gpu = config['use_gpu'] diff --git a/tools/infer_vqa_token_ser_re.py b/tools/infer_vqa_token_ser_re.py index 1e5f6f76..2c7cb5e4 100755 --- a/tools/infer_vqa_token_ser_re.py +++ b/tools/infer_vqa_token_ser_re.py @@ -151,7 +151,7 @@ def preprocess(): ser_config = load_config(FLAGS.config_ser) ser_config = merge_config(ser_config, FLAGS.opt_ser) - logger = get_logger(name='root') + logger = get_logger() # check if set use_gpu=True in paddlepaddle cpu version use_gpu = config['Global']['use_gpu'] diff --git a/tools/program.py b/tools/program.py index 7ff04b41..8ec152bb 100755 --- a/tools/program.py +++ b/tools/program.py @@ -525,7 +525,7 @@ def preprocess(is_train=False): log_file = '{}/train.log'.format(save_model_dir) else: log_file = None - logger = get_logger(name='root', log_file=log_file) + logger = get_logger(log_file=log_file) # check if set use_gpu=True in paddlepaddle cpu version use_gpu = config['Global']['use_gpu'] -- GitLab