workflow.py 文件源码

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

项目:Gank-Alfred-Workflow 作者: hujiaweibujidao 项目源码 文件源码
def logger(self):
        """Create and return a logger that logs to both console and
        a log file.

        Use :meth:`open_log` to open the log file in Console.

        :returns: an initialised :class:`~logging.Logger`

        """

        if self._logger:
            return self._logger

        # Initialise new logger and optionally handlers
        logger = logging.getLogger('workflow')

        if not len(logger.handlers):  # Only add one set of handlers

            fmt = logging.Formatter(
                '%(asctime)s %(filename)s:%(lineno)s'
                ' %(levelname)-8s %(message)s',
                datefmt='%H:%M:%S')

            logfile = logging.handlers.RotatingFileHandler(
                self.logfile,
                maxBytes=1024*1024,
                backupCount=1)
            logfile.setFormatter(fmt)
            logger.addHandler(logfile)

            # console = logging.StreamHandler()
            # console.setFormatter(fmt)
            # logger.addHandler(console)

        logger.setLevel(logging.DEBUG)
        self._logger = logger

        return self._logger
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号