• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python logging.log函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中moat.logging.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: got_entry

			def got_entry(name):
				if key is None and name.startswith("bus."):
					buses.append(name)
				elif len(name)>3 and name[2] == ".":
					entries.append(name)
				else:
					log("onewire",TRACE,"got unrecognized name %s" % (name,))
开发者ID:smurfix,项目名称:MoaT,代码行数:7,代码来源:onewire.py


示例2: get_collect

def get_collect(name, allow_collection=False):
	c = None
	if not len(name):
		return None
	coll = collections

	if allow_collection and name[-1] == "*":
		return coll[Name(*name[:-1])]
	while len(name):
		n = len(name)
		while n > 0:
			try:
				coll = coll[Name(*name[:n])]
			except KeyError:
				n = n-1
			else:
				name = name[n:]
				if c is None: c = coll
				break

		if n == 0:
			try:
				coll = coll[name[0]]
			except KeyError:
				from moat.logging import DEBUG,log
				log(DEBUG,"Contents: "+", ".join(str(x) for x in coll.keys()))
				raise CKeyError(name,coll)
			else:
				name = name[1:]
				if c is None: c = coll
	if not allow_collection and not isinstance(coll,Collected):
		raise CCollError(name)
	return coll
开发者ID:M-o-a-T,项目名称:moat,代码行数:33,代码来源:collect.py


示例3: lineReceived

	def lineReceived(self,data):
		db = ""
		e = ""
		if not data: return # empty line
		if data[0] in PREFIX:
			for d in data[1:]:
				if e:
					try:
						db += chr(eval("0x"+e+d))
					except SyntaxError:
						simple_event("fs20","unknown","hex", data=data)
						return
					e=""
				else:
					e=d
			if e:
				log("fs20",WARN,"fs20 odd length "+data)

			self.datagramReceived(data[0], db, timestamp=self.timestamp)
			self.timestamp = None
		elif data[0] == PREFIX_TIMESTAMP:
			self.timestamp = float(data[1:])
		elif data[0] == "P":
			pass # idle
		elif data[0] == "+":
			log("fs20",DEBUG,"fs20 trace "+data)
		else:
			simple_event("fs20","unknown","prefix", prefix=data[0],data=data[1:])
开发者ID:M-o-a-T,项目名称:moat,代码行数:28,代码来源:fs20avr.py


示例4: _do_measure

	def _do_measure(self):
		log("monitor",TRACE,"Start run",self.name)
		try:
			self.running.clear()
			self.started_at = now()
			self._monitor()
			if self.send_check_event:
				simple_event(self.ectx, "monitor","checked",*self.name)
			if self.new_value is not None:
				self.last_value = self.value
				self.value = self.new_value
				if hasattr(self,"delta"):
					if self.last_value is not None:
						val = self.value-self.last_value
						self._ectx.value_delta = val
						if val >= 0 or self.delta == 0:
							simple_event(self.ectx,"monitor","update",*self.name)
				else:
					simple_event(self.ectx,"monitor","update",*self.name)
		except Exception as e:
			fix_exception(e)
			process_failure(e)
		finally:
			log("monitor",TRACE,"Stop run",self.name)
			self.running.set()
			self._schedule()
开发者ID:smurfix,项目名称:MoaT,代码行数:26,代码来源:monitor.py


示例5: dataReceived

	def dataReceived(self, data):
		self._stop_timer()
		data = self.dbuf+data
		while True:
			xi = len(data)+1
			try: pi = data.index(b'\r')
			except ValueError: pi = xi
			try: ei = data.index(b'\n')
			except ValueError: ei = xi
			if pi==xi and ei==xi:
				break
			if pi < ei:
				self.lbuf = data[:pi].decode('utf-8')
				data = data[pi+1:]
			else:
				msg = data[:ei].decode('utf-8')
				data = data[ei+1:]
				if msg == "" and self.lbuf is not None:
					msg = self.lbuf
					self.lbuf = None
				try:
					self.lineReceived(msg)
				except Exception as e:
					log("fs20",ERROR,msg,e)
					fix_exception(e)
					process_failure(e)

		self.dbuf = data
		self._start_timer()
开发者ID:M-o-a-T,项目名称:moat,代码行数:29,代码来源:fs20avr.py


示例6: up

	def up(self):
		dev = devices[self.device]
		if self.switch is not None and self.switched is None:
			log(DEBUG,"switch low1",self.switch,self.to_low)
			dev.set(self.switch,self.to_low)
			self.switched = False
		return super(OWFSmon,self).up()
开发者ID:smurfix,项目名称:MoaT,代码行数:7,代码来源:onewire.py


示例7: error

	def error(self,err):
		"""An error occurred."""
		if self.result is not None and not self.result.successful:
			log("onewire",DEBUG,"done error: ",self,err)
			self.result.set_exception(err)
		else:
			process_failure(err)
开发者ID:smurfix,项目名称:MoaT,代码行数:7,代码来源:onewire.py


示例8: run

	def run(self,ctx,**k):
		event = self.params(ctx)
		try:
			out = self.ctx.out
		except AttributeError:
			out = sys.stderr
		if not len(event):
			for s,v in LogNames.items():
				print("%d = %s" % (s,v), file=out)
			print(".", file=out)
			return None
		if len(event) > 1:
			log(getattr(logging,event[0].upper()), *event[1:])
		else:
			level = getattr(logging,event[0].upper())
			if level == logging.NONE:
				if hasattr(out,"logger"):
					out.logger.delete()
					del out.logger
			else:
				if hasattr(out,"logger"):
					out.logger.level = level
				else:
					try: out = self.ctx.out
					except AttributeError: out = sys.stderr
					logger = OutLogger(out=out, level=level)
					try: out.logger = logger
					except AttributeError: pass # file objects don't
					except:
						logger.delete()
						raise
开发者ID:smurfix,项目名称:MoaT,代码行数:31,代码来源:logging.py


示例9: exposed_write

	def exposed_write(self,s):
		i = s.find("\n")
		while i >= 0:
			log("TEST",DEBUG,">>>",self.buf+s[:i])
			self.buf = ""
			s = s[i+1:]
			i = s.find("\n")
		self.buf += s
开发者ID:smurfix,项目名称:MoaT,代码行数:8,代码来源:mod_rpc.py


示例10: _init

	def _init(self, bus, short_id=None, id=None, path=()):
		log("onewire",DEBUG,"NEW", bus,short_id,id,path)
		self.bus_id = id
		if short_id:
			self.id = short_id.lower()
		self.bus = bus
		assert path is not None
		self.path = path
		self.is_up = None
		self.ctx = Context()
开发者ID:smurfix,项目名称:MoaT,代码行数:10,代码来源:onewire.py


示例11: do_post

	def do_post(self):
		self.slotter = None
		if self.running != "during" or self.waiter is not None:
			log(ERROR,"timeslot error post",self.running,*self.name)
			return

		self.running = "next"
		simple_event("timeslot","end",*self.name, deprecated=True)
		simple_event("timeslot","state",*self.name, state="end")
		self.next = time_delta(self.interval, now=self.next)-dt.timedelta(0,self.duration)
		self.waiter = callLater(False, self.next, self.do_pre)
开发者ID:M-o-a-T,项目名称:moat,代码行数:11,代码来源:timeslot.py


示例12: _update_all

	def _update_all(self):
		log("onewire",TRACE,"start bus update")
		old_ids = devices.copy()
		new_ids = {}
		seen_ids = {}
		old_bus = set(self.bus_paths.keys())
		new_bus = set()

		def bus_cb(path):
			if path in old_bus:
				old_bus.remove(path)
			else:
				new_bus.add(path)

		for dev in self.all_devices(bus_cb):
			if dev.id in seen_ids:
				continue
			seen_ids[dev.id] = dev
			if dev.id in old_ids:
				del old_ids[dev.id]
			else:
				new_ids[dev.id] = dev

		n_old = 0
		n_dev = 0
		for dev in old_ids.values():
			if dev.bus is self:
				n_old += 1
				## Just because something vanishes from the listing
				## doesn't mean it's dead; the bus may be a bit unstable
				# dev.go_down()
				log("onewire",DEBUG,"Bus unstable?",self.name,dev.id)

		for dev in devices.values():
			if dev.bus is self:
				n_dev += 1
		
		for dev in old_bus:
			bp = self.bus_paths.pop(dev)
			bp.stop()
			simple_event("onewire","bus","down", bus=self.name,path=dev)
			simple_event("onewire","bus","state",self.name,"/".join(dev), bus=self.name,path=dev, state="down")
		for dev in new_bus:
			self.bus_paths[dev] = OWFSbuspath(self,dev)
			simple_event("onewire","bus","up", bus=self.name,path=dev)
			simple_event("onewire","bus","state",self.name,"/".join(dev), bus=self.name,path=dev, state="up")

		# success only, error above
		simple_event("onewire","scanned",*self.name, old=n_old, new=len(new_ids), num=n_dev, deprecated=True)
		simple_event("onewire","scan",*self.name, run="done", old=n_old, new=len(new_ids), num=n_dev)
开发者ID:smurfix,项目名称:MoaT,代码行数:50,代码来源:onewire.py


示例13: lineReceived

	def lineReceived(self, line):
		log("wago",TRACE,"recv",repr(line))
		msgid = 0
		off = 0
		mt = MT_OTHER

		if self.buf is not None:
			if line == ".":
				buf,self.buf = self.buf,None
				self.msgReceived(type=MT_MULTILINE, msg=buf)
			else:
				if line.startswith("."):
					line = line[1:]
				self.buf.append(line)
			return
		elif line == "":
			self.msgReceived(type=MT_OTHER, msg=line)
		elif line[0] == "=":
			self.buf = [line[1:]]
			return
		elif line[0] == "?":
			self.msgReceived(type=MT_ERROR, msg=line[1:].strip())
			return
		elif line[0] == "*":
			self.msgReceived(type=MT_INFO, msg=line[1:].strip())
			return
		elif line[0] == "+":
			self.msgReceived(type=MT_ACK, msg=line[1:].strip())
			return
		elif line[0] == "-":
			self.msgReceived(type=MT_NAK, msg=line[1:].strip())
			return
		elif line[0] == "!":
			if line[1] == "+":
				mt = MT_IND_ACK
				off = 2
			elif line[1] == "-":
				mt = MT_IND_NAK
				off = 2
			else:
				mt = MT_IND
				off = 1
		while off < len(line) and line[off].isdigit():
			msgid = 10*msgid+int(line[off])
			off += 1
		if msgid > 0:
			self.msgReceived(type=mt, msgid=msgid, msg=line[off:].strip())
		else:
			self.msgReceived(type=mt, msg=line.strip())
开发者ID:smurfix,项目名称:MoaT,代码行数:49,代码来源:wago.py


示例14: cont

	def cont(self, _=None):
		while self.waiting:
			try:
				msg = self.waiting.pop(0)
				log("fs20",DEBUG,msg)
				d = self._dataReceived(msg)
			except Exception as e:
				fix_exception(e)
				process_failure(e)
			else:
				if d:
					d.addCallback(self.cont)
					return
		self.waiting = None
		self._start_timer()
开发者ID:M-o-a-T,项目名称:moat,代码行数:15,代码来源:fs20avr.py


示例15: do_pre

	def do_pre(self):
		self.waiter = None
		if self.running != "next" or self.slotter is not None:
			log(ERROR,"timeslot error pre",self.running,*self.name)
			return

		if self.next is None:
			self.next = now()
		self.last = self.next

		self.running = "during"
		simple_event("timeslot","begin",*self.name, deprecated=True)
		simple_event("timeslot","state",*self.name, state="begin")
		self.next += dt.timedelta(0,self.duration)
		self.slotter = callLater(False,self.next, self.do_post)
开发者ID:M-o-a-T,项目名称:moat,代码行数:15,代码来源:timeslot.py


示例16: sendMsg

	def sendMsg(self, typ, data, rlen):
		"""Send an OWFS message to the other end of the connection.
		"""
		flags = 0
		if self.persist:
			flags |= OWFlag.persist
		# needed for sometimes-broken 1wire daemons
		flags |= OWFlag.busret
		# flags |= 1<<8 ## ?
		flags |= OWtempformat.celsius << OWtempformat._offset
		flags |= OWdevformat.fdi << OWdevformat._offset

		log("onewire",DEBUG,"SEND", 0, len(data), typ, flags, rlen, 0, repr(data))
		self.write(struct.pack("!6i", \
			0, len(data), typ, flags, rlen, 0) +data)
开发者ID:smurfix,项目名称:MoaT,代码行数:15,代码来源:onewire.py


示例17: called

def called(env,*a,**k):
    log(TRACE,"PY Proc called",env,a,k)
    env.on("test","me", doc="Test me harder",name="foo test bar")(running)
    env.on("test","me","not", doc="dummy")(not_running)
    if env.test.true():
        env.do.log.DEBUG("true")
    if env.test('false'):
        env.do.log.ERROR("false")
    env.trigger("test","it", what="ever")
    env.do.wait("some delay",_for="0.2 min")
    env.do.wait("more","delay",_for=(0.3,"min"))
    for k in env.data['on']:
        env.do.log.DEBUG("Handler",k)
    env.do("log DEBUG 'do' works")
    env.do.log('DEBUG', "'do.log' works")
    log(TRACE,"PY Proc done")
开发者ID:smurfix,项目名称:MoaT,代码行数:16,代码来源:exec.py


示例18: __init__

	def __init__(self, parent, args, name=None, prio=(MIN_PRIO+MAX_PRIO)//2+1):
		self.prio = prio
		self.displayname = name
		self.args = args
		self.parent = parent

		if name is None:
			name = Name("_on",self._get_id())
		super(OnEventBase,self).__init__(*name)
		for k in self.args:
			if hasattr(k,'startswith') and k.startswith('*'):
				self._simple = False

#		self.name = six.text_type(self.args)
#		if self.displayname is not None:
#			self.name += u" ‹"+" ".join(six.text_type(x) for x in self.displayname)+u"›"

		
		log(TRACE,"NewHandler",self.id)
开发者ID:M-o-a-T,项目名称:moat,代码行数:19,代码来源:event_hook.py


示例19: recv

	def recv(self,msg):
		if msg.type is MT_MULTILINE:
			for x in msg.msg:
				if x == "":
					continue
				m = _num.match(x)
				if m is None:
					continue
				mon = int(m.group(0))
				self.data[mon]=x[m.end():]
				recvs,self.queue.receivers = self.queue.receivers,[]
				for r in recvs:
					mid = getattr(r,"msgid",None)
					if mid is None or mid in self.data:
						log("wago",TRACE,"found monitor",r)
						self.queue.receivers.append(r)
					else:
						try:
							raise DroppedMonitor(mid)
						except DroppedMonitor as ex:
							fix_exception(ex)
							res = r.error(ex)
							if res is SEND_AGAIN:
								log("wago",TRACE,"retry monitor",r)
								self.queue.enqueue(r)
							else:
								log("wago",TRACE,"drop monitor",r)
								assert res is None or res is False, "%s.error returned %s"%(repr(r),repr(res))

			return MINE
		if msg.type is MT_NAK or msg.type is MT_ERROR:
			simple_event("wago","monitor","error", msg=msg.msg)
			return MINE
		return NOT_MINE
开发者ID:smurfix,项目名称:MoaT,代码行数:34,代码来源:wago.py


示例20: filter_data

	def filter_data(self):
		"""Discard outlier values and calculate average"""
		log("monitor",TRACE,"filter",self.data,"on", self.name)

		if len(self.data) < self.points:
			return None
		avg = sum(float(x) for x in self.data)/len(self.data)
		if not self.range:
			return avg

		data = self.data
		while True:
			lo = min(data)
			hi = max(data)
			if hi-lo <= self.range:
				return avg

			if len(data) == self.points:
				break

			new_data = []
			extr = None # stored outlier
			nsum = 0 # new sum
			dif = None # difference for extr
			for val in data:
				ndif = abs(avg-val)
				if dif is None or dif < ndif:
					dif = ndif
					if extr is not None:
						nsum += extr
						new_data.append(extr)
					extr = val
				else:
					nsum += val
					new_data.append(val)
			data = new_data
			avg = nsum/len(data)
		return None
开发者ID:smurfix,项目名称:MoaT,代码行数:38,代码来源:monitor.py



注:本文中的moat.logging.log函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python run.simple_event函数代码示例发布时间:2022-05-27
下一篇:
Python uptime.secs函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap