def debug (message, level=10):
    if timestamp: ts= '%s:'%time.time()
    else: ts = ''
    if level <= debug_level:
        stack = traceback.extract_stack()
        if len(stack) >= 2:
            caller=stack[-2]
            finame=caller[0]
            line = caller[1]
        else:
            finame = " ".join(stack)
            line = ""
        if args.debug_file:
            if debug_file.search(finame):
                print("DEBUG: ",ts,"%s: %s"%(finame,line),message)
        else:
            print("DEBUG: ",ts,"%s: %s"%(finame,line),message)