00001 #!/usr/local/bin/python 00002 # 00003 # Copyright 2004 00004 # by 00005 # The Board of Trustees of the 00006 # Leland Stanford Junior University. 00007 # All rights reserved. 00008 # 00009 00010 00011 __facility__ = "Online" 00012 __abstract__ = "Logging methods" 00013 __author__ = "Selim Tuvi <stuvi@slac.stanford.edu> SLAC - GLAST I&T/Online" 00014 __date__ = ("$Date: 2004/11/05 02:21:49 $").split(' ')[1] 00015 __version__ = "$Revision: 2.8 $" 00016 __release__ = "$Name: R04-12-00 $" 00017 __credits__ = "SLAC" 00018 00019 import LATTE.copyright_SLAC 00020 00021 import sys 00022 import traceback 00023 import logging as log 00024 00025 def logStack(): 00026 for line in traceback.format_stack(): 00027 log.debug(__stripLineFeed(line)) 00028 00029 def logException(msg=""): 00030 etype, value, tb = sys.exc_info() 00031 if tb is None: 00032 logStack() 00033 else: 00034 #for line in traceback.format_exception(etype, value, tb): 00035 # log.error(__stripLineFeed(line)) 00036 log.exception(msg) 00037 00038 def __stripLineFeed(str): 00039 return str.replace('\n', ' ')