Created
August 3, 2010 00:56
-
-
Save huacnlee/505613 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from settings import * | |
import os,time,traceback | |
def write(ex): | |
""" | |
summary: | |
写日志,此功能主要是用于为方便记录运行期的错误,另外也可用做开发时的Ajax调试,为方便得到错误信息 | |
params: | |
ex 文本 或 traceback对象 | |
author: | |
李华顺 <huacnlee@gmail.com> | |
""" | |
text = '' | |
if type(ex) != type(traceback): | |
text = ex | |
else: | |
text = ex.format_exc('') | |
log_text = "\n%s:\n%s\n" % (time.strftime('%Y-%m-%d %H:%M:%S'),text) | |
in_stream = open(ERROR_LOG_FILE_NAME,"ac") | |
in_stream.write("%s" % log_text) | |
in_stream.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment