本文整理汇总了Python中config.LOG_FILE属性的典型用法代码示例。如果您正苦于以下问题:Python config.LOG_FILE属性的具体用法?Python config.LOG_FILE怎么用?Python config.LOG_FILE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类config
的用法示例。
在下文中一共展示了config.LOG_FILE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: log
# 需要导入模块: import config [as 别名]
# 或者: from config import LOG_FILE [as 别名]
def log(message, alert=False):
"""Log messages along with a timestamp in a log file. If the alert
option is set to true, send a message to the admin's reddit inbox.
"""
t = time.strftime('%y-%m-%d %H:%M:%S', time.localtime())
message = "{}: {}\n".format(t, message)
message = message.encode('utf8', 'replace')
if config.LOG_FILE:
with open(config.LOG_FILE, 'a') as f:
f.write(message)
else:
print(message, end='')
if alert and config.ADMIN:
r = praw.Reddit(config.USER_AGENT)
r.login(config.R_USERNAME, config.R_PASSWORD)
admin_alert = message
subject = "CompileBot Alert"
r.redditor(config.ADMIN).message(subject, admin_alert)
示例2: log
# 需要导入模块: import config [as 别名]
# 或者: from config import LOG_FILE [as 别名]
def log(string):
""" Log string to file
"""
with open(config.LOG_FILE, "a+") as f:
f.write("[%s] %s\n" % (timestamp(), string))
示例3: export
# 需要导入模块: import config [as 别名]
# 或者: from config import LOG_FILE [as 别名]
def export():
with open(cfg.LOG_FILE, 'w') as lfile:
lfile.write(log)