#!/usr/bin/env python """ * Copyright (c) 2008, David Draco * All rights reserved. * I declare this code public domain. """ """ * These are bindings for Python to nldebug * see http://nldebug.sourceforge.net/ """ import socket import time import traceback udp_debugging_with_timestamps = True udp_debugging_with_tracebacks = True def send_udp_message(dest, port, content): sd = socket.socket(socket.AF_INET,socket.SOCK_DGRAM) sd.sendto(content, (dest, port)) def udpdebug(line): if udp_debugging_with_timestamps: line = "%d: %s" % (int(time.time()), line) if udp_debugging_with_tracebacks: trace = traceback.extract_stack() trace.pop() # thats us line = line + "\n\n" for i in range(len(trace)): line = line + " "*i + "%s:%d function %s: %s\n" % trace[i] send_udp_message("localhost", 5542, line)