本文整理匯總了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)