How to print error tracking:
Method 1. Print to screen
Try
i = 0
Mydbhandler.executemany (SQL, TMP)
Logging.info ("[Total cost Time:" + str (time.time ()-start) *1000) + "Ms]"
Print "Total cost time:", (Time.time ()-start) *1000, "MS"
Except
EType, evalue, tracebackobj = Sys.exc_info () [: 3]
print ' Type: ', etype
Print "Value:", Evalue
TRACEBACK.PRINT_TB (Tracebackobj)
Method 2. Print to File
Import logging
Log_filename = '/tmp/logging_example.out '
Logging.basicconfig (filename=log_filename,level=logging. DEBUG,)
#log Print Format configuration
#logging. Basicconfig (filename=log_filename,level=logging. debug,format= ' [% (asctime) s]% (levelname) s:% (filename) s:% (funcName) s:% (message) s ',)
Logging.debug (' This message should go to the log file ')
Try
i = 0
Mydbhandler.executemany (SQL, TMP)
Logging.info ("[Total cost Time:" + str (time.time ()-start) *1000) + "Ms]"
Print "Total cost time:", (Time.time ()-start) *1000, "MS"
Except
EType, evalue, tracebackobj = Sys.exc_info () [: 3]
print ' Type: ', etype
Print "Value:", Evalue
Logging.exception (' Got exception on main handler ')
Raise
Note: Logging is a
reference that can be configured in print format:
Http://stackoverflow.com/questions/1508467/how-to-log-my-traceback-error
http://groups.google.com/group/python-tornado/browse_thread/thread/acf41c6e03045a4c#