X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FDebug.py;h=b120871a17a6f6f80f9f31633bce0be570734a5e;hb=19d4a01ccf66af9e00914351b3eacd5fc880f988;hp=ccd7db711413be51bfbfeab083fdf63cb12f69f2;hpb=24d16d18acab3da7bccc3e09df4927e9cf2d3246;p=plcapi.git diff --git a/PLC/Debug.py b/PLC/Debug.py index ccd7db7..b120871 100644 --- a/PLC/Debug.py +++ b/PLC/Debug.py @@ -1,19 +1,9 @@ +# log system for PLCAPI import time import sys import syslog -class unbuffered: - """ - Write to /var/log/httpd/error_log. See - - http://www.modpython.org/FAQ/faqw.py?req=edit&file=faq02.003.htp - """ - - def write(self, data): - sys.stderr.write(data) - sys.stderr.flush() - -log = unbuffered() +from PLC.Logger import logger def profile(callable): """ @@ -40,14 +30,15 @@ def profile(callable): end = time.time() args = map(str, args) args += ["%s = %s" % (name, str(value)) for (name, value) in kwds.items()] - print >> log, "%s (%s): %f s" % (callable.__name__, ", ".join(args), end - start) + logger.info("%s (%s): %f s" % (callable.__name__, ", ".join(args), end - start)) return result return wrapper if __name__ == "__main__": - @profile def sleep(seconds = 1): time.sleep(seconds) + sleep = profile(sleep) + sleep(1)