本文整理汇总了Python中tcf.protocol.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doneGetContext
def doneGetContext(self, token, error, ctx):
pending.remove(token)
if error:
protocol.log("Error from Registers.getContext", error)
else:
print ctx
if ctx.isReadable() and not ctx.isReadOnce() and ctx.getSize() >= 2:
locs = []
locs.append(registers.Location(ctx.getID(), 0, 1))
locs.append(registers.Location(ctx.getID(), 1, 1))
class DoneGetM(registers.DoneGet):
def doneGet(self, token, error, value):
pending.remove(token)
if error:
protocol.log("Error from Registers.getm", error)
else:
print "getm", ctx.getID(), map(ord, value)
if not pending:
onDone()
pending.append(regs.getm(locs, DoneGetM()))
if ctx.isWriteable() and not ctx.isWriteOnce() and ctx.getSize() >= 2:
locs = []
locs.append(registers.Location(ctx.getID(), 0, 1))
locs.append(registers.Location(ctx.getID(), 1, 1))
class DoneSetM(registers.DoneSet):
def doneGet(self, token, error):
pending.remove(token)
if error:
protocol.log("Error from Registers.setm", error)
if not pending:
onDone()
pending.append(regs.setm(locs, (255, 255), DoneSetM()))
if not pending:
onDone()
示例2: doneGet
def doneGet(self, token, error, mmap):
if error:
protocol.log("Error from PathMap.get", error)
else:
print mmap
with lock:
lock.notify()
示例3: __init__
def __init__(self, service, name, data):
self.service = service
self.name = name
try:
self.args = channel.fromJSONSequence(data)
except Exception as x:
protocol.log("Error decoding event data", x)
示例4: doneGetContext
def doneGetContext(self, token, error, context):
pending.remove(token)
if error:
protocol.log("Error from RunControl.getContext", error)
else:
print context
class DoneGetState(runcontrol.DoneGetState):
def doneGetState(self, token, error, suspended, pc, reason,
params):
pending.remove(token)
if error:
protocol.log(
"Error from RunControl.getState", error)
else:
print "suspended: ", suspended
print "pc: ", pc
print "reason: ", reason
print "params: ", params
if suspended:
_suspended.append(context.getID())
if len(pending) == 0:
with lock:
lock.notify()
if context and context.hasState():
pending.append(context.getState(DoneGetState()))
if len(pending) == 0:
with lock:
lock.notify()
示例5: doneGetChildren
def doneGetChildren(self, token, error, context_ids):
if error:
protocol.log("Error from Processes.GetChildren", error)
else:
print "Processes:", context_ids
with lock:
lock.notify()
示例6: _log
def _log(self, msg, x):
if not self._alive: return
# Don't report same error multiple times to avoid filling up the log file.
with self._error_log_lock:
if msg in self.error_log: return
self.error_log.add(msg)
protocol.log(msg, x)
示例7: doneCommand
def doneCommand(self, token, error):
if error:
protocol.log("Error from RunControl.resume", error)
else:
context.suspend(runcontrol.DoneCommand())
with lock:
lock.notify()
示例8: doneGet
def doneGet(self, token, error, value):
pending.remove(token)
if error:
protocol.log("Error from Registers.getm", error)
else:
print "getm", ctx.getID(), map(ord, value)
if not pending:
onDone()
示例9: __traceMessageReceived
def __traceMessageReceived(self, m):
for l in self.trace_listeners:
try:
id = None
if m.token is not None:
id = m.token.getID()
l.onMessageReceived(m.type, id, m.service, m.name, m.data)
except Exception as x:
protocol.log("Exception in channel listener", x)
示例10: doneCommand
def doneCommand(self, token, error):
"""Called when run control command execution is complete.
:param token: pending command handle.
:param error: command execution error or **None**.
"""
if error:
protocol.log("Error from RunContext.resume", error)
with condition:
condition.notify()
示例11: doneGetChildren
def doneGetChildren(self, token, error, context_ids):
pending.remove(token)
if error:
protocol.log("Error from RunControl.GetChildren", error)
else:
for c in context_ids:
contexts.append(c)
pending.append(rc.getChildren(c, self))
if len(pending) == 0:
cache.set(None, None, contexts)
示例12: trace
def trace(msg):
"""
Trace hooks should use this method to log a message. It prepends the
message with a timestamp and sends it to the TCF logger facility. The
logger implementation may or may not inject its own timestamp. For
tracing, we definitely need one, so we introduce a minimal, relative-time
stamp.
@param msg the trace message
"""
protocol.log('%s %s' % (getDebugTime(), msg))
示例13: doneSubscribe
def doneSubscribe(self, token, error):
"""Called when stream subscription is done.
:param token: pending command handle
:param error: error description if operation failed, **None**
if succeeded.
"""
if error:
protocol.log("Error from streams.subscribe()", error)
with condition:
condition.notify()
示例14: sendPeerRemovedEvent
def sendPeerRemovedEvent(self):
for l in protocol.getLocator().getListeners():
try:
l.peerRemoved(self.rw_attrs.get(ATTR_ID))
except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
try:
args = [self.rw_attrs.get(ATTR_ID)]
protocol.sendEvent(locator.NAME, "peerRemoved", json.dumps(args))
except IOError as x:
protocol.log("Locator: failed to send 'peerRemoved' event", x)
示例15: doneGet
def doneGet(self, token, error, value):
pending.remove(token)
if error:
protocol.log(
"Error from Registers.getm",
error)
else:
print("getm " + str(ctx.getID()) +
" " +
str(list(map(int, value))))
if not pending:
onDone()