当前位置: 首页>>代码示例>>Golang>>正文


Golang logging.Warn函数代码示例

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


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

示例1: GetRand

// TODO(fluffle): thisisn't quite PseudoRand but still ...
func (uc *Collection) GetRand(regex string) *Url {
	lookup := bson.M{}
	if regex != "" {
		// Perform a regex lookup if we have one
		lookup["url"] = bson.M{"$regex": regex, "$options": "i"}
	}
	query := uc.Find(lookup)
	count, err := query.Count()
	if err != nil {
		logging.Warn("Count for URL lookup '%s' failed: %s", regex, err)
		return nil
	}
	if count == 0 {
		return nil
	}
	var res Url
	if count > 1 {
		query.Skip(rand.Intn(count))
	}
	if err = query.One(&res); err != nil {
		logging.Warn("Fetch for URL lookup '%s' failed: %s", regex, err)
		return nil
	}
	return &res
}
开发者ID:gundalow,项目名称:sp0rkle,代码行数:26,代码来源:urls.go

示例2: DelNick

// Removes a Nick from being tracked.
func (st *stateTracker) DelNick(n string) {
	if nk, ok := st.nicks[n]; ok {
		if nk != st.me {
			st.delNick(nk)
		} else {
			logging.Warn("Tracker.DelNick(): won't delete myself.")
		}
	} else {
		logging.Warn("Tracker.DelNick(): %s not tracked.", n)
	}
}
开发者ID:Gonk,项目名称:goirc,代码行数:12,代码来源:tracker.go

示例3: GetPseudoRand

// TODO(fluffle): reduce duplication with lib/factoids?
func (qc *Collection) GetPseudoRand(regex string) *Quote {
	lookup := bson.M{}
	if regex != "" {
		// Only perform a regex lookup if there's a regex to match against,
		// otherwise this just fetches a quote at pseudo-random.
		lookup["quote"] = bson.M{"$regex": regex, "$options": "i"}
	}
	ids, ok := qc.seen[regex]
	if ok && len(ids) > 0 {
		logging.Debug("Looked for quotes matching '%s' before, %d stored id's",
			regex, len(ids))
		lookup["_id"] = bson.M{"$nin": ids}
	}
	query := qc.Find(lookup)
	count, err := query.Count()
	if err != nil {
		logging.Warn("Count for quote lookup '%s' failed: %s", regex, err)
		return nil
	}
	if count == 0 {
		if ok {
			// Looked for this regex before, but nothing matches now
			delete(qc.seen, regex)
		}
		return nil
	}
	var res Quote
	if count > 1 {
		query = query.Skip(rand.Intn(count))
	}
	if err = query.One(&res); err != nil {
		logging.Warn("Fetch for quote lookup '%s' failed: %s", regex, err)
		return nil
	}
	if count != 1 {
		if !ok {
			// only store seen for regex that match more than one quote
			logging.Debug("Creating seen data for regex '%s'.", regex)
			qc.seen[regex] = make([]bson.ObjectId, 0, count)
		}
		logging.Debug("Storing id %v for regex '%s'.", res.Id, regex)
		qc.seen[regex] = append(qc.seen[regex], res.Id)
	} else if ok {
		// if the count of results is 1 and we're storing seen data for regex
		// then we've exhausted the possible results and should wipe it
		logging.Debug("Zeroing seen data for regex '%s'.", regex)
		delete(qc.seen, regex)
	}
	return &res
}
开发者ID:gundalow,项目名称:sp0rkle,代码行数:51,代码来源:quotes.go

示例4: Dissociate

// Dissociates an already known nick from an already known channel.
// Does some tidying up to stop tracking nicks we're no longer on
// any common channels with, and channels we're no longer on.
func (st *stateTracker) Dissociate(ch *Channel, nk *Nick) {
	if ch == nil || nk == nil {
		logging.Error("Tracker.Dissociate(): passed nil values :-(")
	} else if _ch, ok := st.chans[ch.Name]; !ok || ch != _ch {
		// As we can implicitly delete both nicks and channels from being
		// tracked by dissociating one from the other, we should verify that
		// we're not being passed an old Nick or Channel.
		logging.Error("Tracker.Dissociate(): channel %s not found in "+
			"(or differs from) internal state.", ch.Name)
	} else if _nk, ok := st.nicks[nk.Nick]; !ok || nk != _nk {
		logging.Error("Tracker.Dissociate(): nick %s not found in "+
			"(or differs from) internal state.", nk.Nick)
	} else if _, ok := nk.IsOn(ch); !ok {
		logging.Warn("Tracker.Dissociate(): %s not on %s.",
			nk.Nick, ch.Name)
	} else if nk == st.me {
		// I'm leaving the channel for some reason, so it won't be tracked.
		st.delChannel(ch)
	} else {
		// Remove the nick from the channel and the channel from the nick.
		ch.delNick(nk)
		nk.delChannel(ch)
		if len(nk.chans) == 0 {
			// We're no longer in any channels with this nick.
			st.delNick(nk)
		}
	}
}
开发者ID:Gonk,项目名称:goirc,代码行数:31,代码来源:tracker.go

示例5: Associate

// Associates an already known nick with an already known channel.
func (st *stateTracker) Associate(ch *Channel, nk *Nick) *ChanPrivs {
	if ch == nil || nk == nil {
		logging.Error("Tracker.Associate(): passed nil values :-(")
		return nil
	} else if _ch, ok := st.chans[ch.Name]; !ok || ch != _ch {
		// As we can implicitly delete both nicks and channels from being
		// tracked by dissociating one from the other, we should verify that
		// we're not being passed an old Nick or Channel.
		logging.Error("Tracker.Associate(): channel %s not found in "+
			"(or differs from) internal state.", ch.Name)
		return nil
	} else if _nk, ok := st.nicks[nk.Nick]; !ok || nk != _nk {
		logging.Error("Tracker.Associate(): nick %s not found in "+
			"(or differs from) internal state.", nk.Nick)
		return nil
	} else if _, ok := nk.IsOn(ch); ok {
		logging.Warn("Tracker.Associate(): %s already on %s.",
			nk.Nick, ch.Name)
		return nil
	}
	cp := new(ChanPrivs)
	ch.addNick(nk, cp)
	nk.addChannel(ch, cp)
	return cp
}
开发者ID:Gonk,项目名称:goirc,代码行数:26,代码来源:tracker.go

示例6: DelChannel

// Removes a Channel from being tracked.
func (st *stateTracker) DelChannel(c string) {
	if ch, ok := st.chans[c]; ok {
		st.delChannel(ch)
	} else {
		logging.Warn("Tracker.DelChannel(): %s not tracked.", c)
	}
}
开发者ID:Gonk,项目名称:goirc,代码行数:8,代码来源:tracker.go

示例7: InfoMR

func (fc *Collection) InfoMR(key string) *FactoidInfo {
	mr := &mgo.MapReduce{
		Map: `function() { emit("count", {
			accessed: this.accessed.count,
			modified: this.modified.count,
			created: this.created.count,
		})}`,
		Reduce: `function(k,l) {
			var sum = { accessed: 0, modified: 0, created: 0 };
			for each (var v in l) {
				sum.accessed += v.accessed;
				sum.modified += v.modified;
				sum.created  += v.created;
			}
			return sum;
		}`,
	}
	var res []struct {
		Id    int `bson:"_id"`
		Value FactoidInfo
	}
	info, err := fc.Find(lookup(key)).MapReduce(mr, &res)
	if err != nil || len(res) == 0 {
		logging.Warn("Info MR for '%s' failed: %v", key, err)
		return nil
	} else {
		logging.Debug("Info MR mapped %d, emitted %d, produced %d in %d ms.",
			info.InputCount, info.EmitCount, info.OutputCount, info.Time/1e6)
	}
	return &res[0].Value
}
开发者ID:fluffle,项目名称:sp0rkle,代码行数:31,代码来源:factoids.go

示例8: h_JOIN

// Handle JOINs to channels to maintain state
func (conn *Conn) h_JOIN(line *Line) {
	ch := conn.ST.GetChannel(line.Args[0])
	nk := conn.ST.GetNick(line.Nick)
	if ch == nil {
		// first we've seen of this channel, so should be us joining it
		// NOTE this will also take care of nk == nil && ch == nil
		if nk != conn.Me {
			logging.Warn("irc.JOIN(): JOIN to unknown channel %s received "+
				"from (non-me) nick %s", line.Args[0], line.Nick)
			return
		}
		ch = conn.ST.NewChannel(line.Args[0])
		// since we don't know much about this channel, ask server for info
		// we get the channel users automatically in 353 and the channel
		// topic in 332 on join, so we just need to get the modes
		conn.Mode(ch.Name)
		// sending a WHO for the channel is MUCH more efficient than
		// triggering a WHOIS on every nick from the 353 handler
		conn.Who(ch.Name)
	}
	if nk == nil {
		// this is the first we've seen of this nick
		nk = conn.ST.NewNick(line.Nick)
		nk.Ident = line.Ident
		nk.Host = line.Host
		// since we don't know much about this nick, ask server for info
		conn.Who(nk.Nick)
	}
	// this takes care of both nick and channel linking \o/
	conn.ST.Associate(ch, nk)
}
开发者ID:Jyggafey,项目名称:drone,代码行数:32,代码来源:state_handlers.go

示例9: _console_log

func _console_log(args ...interface{}) interface{} {
	for _, arg := range args {
		log.Warn("> %s", arg)
	}

	return ""
}
开发者ID:Gonk,项目名称:Gonk,代码行数:7,代码来源:module.go

示例10: NewChannel

// Creates a new Channel, initialises it, and stores it so it
// can be properly tracked for state management purposes.
func (st *stateTracker) NewChannel(c string) *Channel {
	if _, ok := st.chans[c]; ok {
		logging.Warn("Tracker.NewChannel(): %s already tracked.", c)
		return nil
	}
	st.chans[c] = NewChannel(c)
	return st.chans[c]
}
开发者ID:Gonk,项目名称:goirc,代码行数:10,代码来源:tracker.go

示例11: NewNick

// Creates a new Nick, initialises it, and stores it so it
// can be properly tracked for state management purposes.
func (st *stateTracker) NewNick(n string) *Nick {
	if _, ok := st.nicks[n]; ok {
		logging.Warn("Tracker.NewNick(): %s already tracked.", n)
		return nil
	}
	st.nicks[n] = NewNick(n)
	return st.nicks[n]
}
开发者ID:Gonk,项目名称:goirc,代码行数:10,代码来源:tracker.go

示例12: TopTen

func (sc *Collection) TopTen(ch string) []Nick {
	var res []Nick
	q := sc.Find(bson.M{"action": "LINES", "chan": ch}).Sort("-lines").Limit(10)
	if err := q.All(&res); err != nil {
		logging.Warn("TopTen Find error: %v", err)
	}
	return res
}
开发者ID:pzsz,项目名称:sp0rkle,代码行数:8,代码来源:seen.go

示例13: h_671

// Handle 671 whois reply (nick connected via SSL)
func (conn *Conn) h_671(line *Line) {
	if nk := conn.ST.GetNick(line.Args[1]); nk != nil {
		nk.Modes.SSL = true
	} else {
		logging.Warn("irc.671(): received WHOIS SSL info for unknown nick %s",
			line.Args[1])
	}
}
开发者ID:Jyggafey,项目名称:drone,代码行数:9,代码来源:state_handlers.go

示例14: h_TOPIC

// Handle TOPIC changes for channels
func (conn *Conn) h_TOPIC(line *Line) {
	if ch := conn.ST.GetChannel(line.Args[0]); ch != nil {
		ch.Topic = line.Args[1]
	} else {
		logging.Warn("irc.TOPIC(): topic change on unknown channel %s",
			line.Args[0])
	}
}
开发者ID:Jyggafey,项目名称:drone,代码行数:9,代码来源:state_handlers.go

示例15: h_332

// Handle 332 topic reply on join to channel
func (conn *Conn) h_332(line *Line) {
	if ch := conn.ST.GetChannel(line.Args[1]); ch != nil {
		ch.Topic = line.Args[2]
	} else {
		logging.Warn("irc.332(): received TOPIC value for unknown channel %s",
			line.Args[1])
	}
}
开发者ID:Jyggafey,项目名称:drone,代码行数:9,代码来源:state_handlers.go


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