def dbg(msg, l=1): ''' if global debug is set to true, be more verbose ''' import inspect msg = lt.to_string(msg) if hasattr(msg, '__iter__'): msg = ' '.join(msg) if debug >= l: curf = inspect.currentframe() calf = inspect.getouterframes(curf, 2) file, line, method = calf[1][1:4] file = file.split('/')[-1] print '[%s.%s.%i] %s' % (file, method, line, msg)
def dbg( msg, l=1 ): ''' if global debug is set to true, be more verbose msg : str, Message to be printed l : int, Debug level of message. Set higher for lower level messages. As debug increases, noisiness should also. ''' msg = lt.to_string( msg ) if hasattr( msg, '__iter__'): msg = ' '.join( msg ) import inspect if debug >= l: curf = inspect.currentframe() calf = inspect.getouterframes( curf, 2 ) file, line, method = calf[1][1:4] print '[%s.%s.%i] %s' % ( file, method, line, msg )
def error_msg( msg, pipe=None, **kwargs ): ''' if global debug is set to true, be more verbose msg : str, Message to be printed l : int, Debug level of message. Set higher for lower level messages. As debug increases, noisiness should also. ''' import inspect msg = lt.to_string( msg ) if hasattr( msg, '__iter__'): msg = ' '.join( msg ) if pipe != None: pipe.send(False) pipe.close() curf = inspect.currentframe() calf = inspect.getouterframes( curf, 2 ) file, line, method = calf[1][1:4] raise RuntimeError, '[%s.%s.%i] %s' % ( file, method, line, msg )