本文整理汇总了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",
#.........这里部分代码省略.........