Commit b3c871b2 authored by Guido van Rossum's avatar Guido van Rossum

Two unrelated niceties:

1) An option to add the thread name to the label.  This is very handy
   during heavy debugging, but also very expensive (two extra function
   calls and some string formatting), so it is off by default; you
   have to edit this file to enable it.

2) In short_repr(), for strings, show the string quote after the three
   trailing dots.
parent 17a81b48
......@@ -14,6 +14,9 @@
import os
import types
import zLOG
import threading
LOG_THREAD_ID = 0 # Set this to 1 during heavy debugging
_label = "zrpc:%s" % os.getpid()
......@@ -22,7 +25,10 @@ def new_label():
_label = "zrpc:%s" % os.getpid()
def log(message, level=zLOG.BLATHER, label=None, error=None):
zLOG.LOG(label or _label, level, message, error=error)
label = label or _label
if LOG_THREAD_ID:
label = "%s:%s" % (label, threading.currentThread().getName())
zLOG.LOG(label, level, message, error=error)
REPR_LIMIT = 40
......@@ -40,7 +46,13 @@ def short_repr(obj):
# module name in the pickle.
if isinstance(obj, types.StringType):
r = `obj[:REPR_LIMIT]`
if len(obj) > REPR_LIMIT:
r = repr(obj[:REPR_LIMIT])
else:
r = repr(obj)
if len(r) > REPR_LIMIT:
r = r[:REPR_LIMIT-4] + '...' + r[-1]
return r
elif isinstance(obj, types.TupleType):
elts = []
size = 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment