import sys, traceback EXIT_SUCCESS=0 EXIT_ERROR=1 def info(message): # print info to sys.stderr because it isn’t really output, just debug information print("INFO: "+str(message), file=sys.stderr) traceback.print_stack() def warn(message, is_exception=False): print("WARNING: "+str(message), file=sys.stderr) if is_exception: traceback.print_exc() else: traceback.print_stack() def error(message, is_exception=True, handle_gracefully=True): print("ERROR: "+str(message), file=sys.stderr) if is_exception: traceback.print_exc() else: traceback.print_stack() if handle_gracefully: pass else: sys.exit(EXIT_ERROR)