1 # log system for PLCAPI
8 Write to /var/log/httpd/error_log. See
10 http://www.modpython.org/FAQ/faqw.py?req=edit&file=faq02.003.htp
13 def write(self, data):
14 sys.stderr.write(data)
19 def profile(callable):
21 Prints the runtime of the specified callable. Use as a decorator, e.g.,
35 result = profile(foo)(...)
38 def wrapper(*args, **kwds):
40 result = callable(*args, **kwds)
42 params = map(str, args)
43 params += ["{} = {}".format(name, value) for (name, value) in kwds.items()]
44 params = ", ".join(params)
45 print >> log, "{} ({}) {:f}s -> {}".format(callable.__name__, params, end - start, result)
50 if __name__ == "__main__":
51 def sleep(seconds = 1):
54 sleep = profile(sleep)