ding.utils.log_helper¶
ding.utils.log_helper
¶
TBLoggerFactory
¶
Bases: object
Overview
TBLoggerFactory is a factory class for SummaryWriter.
Interfaces:
create_logger
Properties:
- tb_loggers (:obj:Dict[str, SummaryWriter]): A dict that stores SummaryWriter instances.
LoggerFactory
¶
Bases: object
Overview
LoggerFactory is a factory class for logging.Logger.
Interfaces:
create_logger, get_tabulate_vars, get_tabulate_vars_hor
create_logger(path, name='default', level=logging.INFO)
classmethod
¶
Overview
Create logger using logging
Arguments:
- name (:obj:str): Logger's name
- path (:obj:str): Logger's save dir
- level (:obj:int or :obj:str): Used to set the level. Reference: Logger.setLevel method.
Returns:
- (:obj:logging.Logger): new logging logger
get_tabulate_vars(variables)
staticmethod
¶
Overview
Get the text description in tabular form of all vars
Arguments:
- variables (:obj:List[str]): Names of the vars to query.
Returns:
- string (:obj:str): Text description in tabular form of all vars
get_tabulate_vars_hor(variables)
staticmethod
¶
Overview
Get the text description in tabular form of all vars
Arguments:
- variables (:obj:List[str]): Names of the vars to query.
build_logger(path, name=None, need_tb=True, need_text=True, text_level=logging.INFO)
¶
Overview
Build text logger and tensorboard logger.
Arguments:
- path (:obj:str): Logger(Textlogger & SummaryWriter)'s saved dir
- name (:obj:str): The logger file name
- need_tb (:obj:bool): Whether SummaryWriter instance would be created and returned
- need_text (:obj:bool): Whether loggingLogger instance would be created and returned
- text_level (:obj:int`` or :obj:str): Logging level of ``logging.Logger``, default set to ``logging.INFO``
Returns:
- logger (:obj:Optional[logging.Logger]): Logger that displays terminal output
- tb_logger (:obj:Optional['SummaryWriter']`): Saves output to tfboard, only return when need_tb.
pretty_print(result, direct_print=True)
¶
Overview
Print a dict result in a pretty way
Arguments:
- result (:obj:dict): The result to print
- direct_print (:obj:bool): Whether to print directly
Returns:
- string (:obj:str): The pretty-printed result in str format
Full Source Code
../ding/utils/log_helper.py