Skip to content

Instantly share code, notes, and snippets.

@huacnlee
Created August 3, 2010 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huacnlee/505613 to your computer and use it in GitHub Desktop.
Save huacnlee/505613 to your computer and use it in GitHub Desktop.
# -*- 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