928
934
level = opt['level']
930
936
level = logging.getLogger('madgraph').level
932
level = 10 #avoid info level
937
#print "madgraph level",level
939
# level = 10 #avoid info level
933
941
lineno = inspect.currentframe().f_back.f_lineno
934
942
fargs = inspect.getframeinfo(inspect.currentframe().f_back)
935
943
filename, lineno = fargs[:2]
936
944
#file = inspect.currentframe().f_back.co_filename
937
945
#print type(file)
940
log.log(level, ' '.join([str(a) for a in args]) + \
941
'\nraised at %s at line %s ' % (filename, lineno))
947
source = inspect.getsourcelines(inspect.currentframe().f_back)
948
line = source[0][lineno-source[1]]
949
line = re.findall(r"misc\.sprint\(\s*(.*)\)\s*($|#)", line)[0][0]
950
if line.startswith("'") and line.endswith("'") and line.count(",") ==0:
952
elif line.startswith("\"") and line.endswith("\"") and line.count(",") ==0:
954
elif line.startswith(("\"","'")) and len(args)==1 and "%" in line:
960
intro = ' %s = \033[0m' % line
965
log.log(level, ' '.join([intro]+[str(a) for a in args]) + \
966
' \033[1;30m[%s at line %s]\033[0m' % (os.path.basename(filename), lineno))
945
969
################################################################################