当前位置: 首页>>代码示例>>Python>>正文


Python Plugin.log方法代码示例

本文整理汇总了Python中Plugin.Plugin.log方法的典型用法代码示例。如果您正苦于以下问题:Python Plugin.log方法的具体用法?Python Plugin.log怎么用?Python Plugin.log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plugin.Plugin的用法示例。


在下文中一共展示了Plugin.log方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Logger

# 需要导入模块: from Plugin import Plugin [as 别名]
# 或者: from Plugin.Plugin import log [as 别名]
class Logger(object):
    def __init__(self, opt):
        if "plugin" not in opt:
            raise ValueError("no plugin selected")
        self.botId = self._pickAName()
        self.params = opt
        self.logger = Plugin().load("plugins/Logger_" + opt["plugin"] + ".py")
        self.logger.constructor(self.params)

    def log(self, message, opt={}):
        opt["original_message"] = message
        opt["botId"] = self.botId
        opt["datetime"] = datetime.today()

        if "level" not in opt:
            opt["level"] = "INFO"

        if "exception" in opt:
            exc_type, exc_value, exc_traceback = opt["exception"]
            lines = format_exception(exc_type, exc_value, exc_traceback)
            error = "".join(" " + line for line in lines) + "\n\n   "
            message += error + "\n   "

        self.logger.log(message, opt)

    def _pickAName(self):
        # taken from docker
        names = [
            "albattani",
            "allen",
            "almeida",
            "archimedes",
            "ardinghelli",
            "aryabhata",
            "austin",
            "babbage",
            "banach",
            "bardeen",
            "bartik",
            "bassi",
            "bell",
            "bhabha",
            "bhaskara",
            "blackwell",
            "bohr",
            "booth",
            "borg",
            "bose",
            "boyd",
            "brahmagupta",
            "brattain",
            "brown",
            "carson",
            "chandrasekhar",
            "colden",
            "cori",
            "cray",
            "curie",
            "darwin",
            "davinci",
            "dijkstra",
            "dubinsky",
            "easley",
            "einstein",
            "elion",
            "engelbart",
            "euclid",
            "euler",
            "fermat",
            "fermi",
            "feynman",
            "franklin",
            "galileo",
            "gates",
            "goldberg",
            "goldstine",
            "goldwasser",
            "golick",
            "goodall",
            "hamilton",
            "hawking",
            "heisenberg",
            "heyrovsky",
            "hodgkin",
            "hoover",
            "hopper",
            "hugle",
            "hypatia",
            "jang",
            "jennings",
            "jepsen",
            "joliot",
            "jones",
            "kalam",
            "kare",
            "keller",
            "khorana",
            "kilby",
            "kirch",
            "knuth",
#.........这里部分代码省略.........
开发者ID:mickael-kerjean,项目名称:crawlr,代码行数:103,代码来源:Logger.py


注:本文中的Plugin.Plugin.log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。