inkext.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:tcnc 作者: utlco 项目源码 文件源码
def create_log(self, log_path=None, log_level='DEBUG'):
        """Create a log file for debug output.

        Args:
            log_path: Path to log file. If None or empty
                the log path name will be the
                command line invocation name (argv[0]) with
                a '.log' suffix in the user's home directory.
            log_level: Log level:
                'DEBUG', 'INFO', 'WARNING', 'ERROR', or 'CRITICAL'.
                Default is 'DEBUG'.
        """
        if log_path is None or not log_path:
            log_dir = os.path.expanduser('~')
            log_path = os.path.join(log_dir, sys.argv[0] + '.log')
        log_path = os.path.expanduser(log_path)
        logging.basicConfig(filename=os.path.abspath(log_path),
                            filemode='w', level=log_level.upper())
        logger = logging.getLogger(__name__)
        logger.info('Log started %s, level=%s', datetime.datetime.now(),
                    logging.getLevelName(logger.getEffectiveLevel()))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号