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

Golang logging.Error函数代码示例

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

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



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

示例1: Associate

// Associates an already known nick with an already known channel.
func (st *stateTracker) Associate(c, n string) *ChanPrivs {
	st.mu.Lock()
	defer st.mu.Unlock()
	nk, nok := st.nicks[n]
	ch, cok := st.chans[c]

	if !cok {
		// 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 "+
			"internal state.", c)
		return nil
	} else if !nok {
		logging.Error("Tracker.Associate(): nick %s not found in "+
			"internal state.", n)
		return nil
	} else if _, ok := nk.isOn(ch); ok {
		logging.Warn("Tracker.Associate(): %s already on %s.",
			nk, ch)
		return nil
	}
	cp := new(ChanPrivs)
	ch.addNick(nk, cp)
	nk.addChannel(ch, cp)
	return cp.Copy()
}
开发者ID:mephux,项目名称:komanda-cli,代码行数:28,代码来源:tracker.go


示例2: 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:Kovensky,项目名称:go-lastfm-bot,代码行数:31,代码来源:tracker.go


示例3: 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:Kovensky,项目名称:go-lastfm-bot,代码行数:26,代码来源:tracker.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(c, n string) {
	st.mu.Lock()
	defer st.mu.Unlock()
	nk, nok := st.nicks[n]
	ch, cok := st.chans[c]

	if !cok {
		// 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 "+
			"internal state.", c)
	} else if !nok {
		logging.Error("Tracker.Dissociate(): nick %s not found in "+
			"internal state.", n)
	} 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:mephux,项目名称:komanda-cli,代码行数:34,代码来源:tracker.go


示例5: remove

func (hs *hSet) remove(hn *hNode) {
	hs.Lock()
	defer hs.Unlock()
	l, ok := hs.set[hn.event]
	if !ok {
		logging.Error("Removing node for unknown event '%s'", hn.event)
		return
	}
	if hn.next == nil {
		l.end = hn.prev
	} else {
		hn.next.prev = hn.prev
	}
	if hn.prev == nil {
		l.start = hn.next
	} else {
		hn.prev.next = hn.next
	}
	hn.next = nil
	hn.prev = nil
	hn.set = nil
	if l.start == nil || l.end == nil {
		delete(hs.set, hn.event)
	}
}
开发者ID:StalkR,项目名称:goirc,代码行数:25,代码来源:dispatch.go


示例6: pushAuthHTTP

func pushAuthHTTP(rw http.ResponseWriter, req *http.Request) {
	if err := req.ParseForm(); err != nil {
		http.Redirect(rw, req, pushFailureURL("parse"), 302)
		return
	}
	if req.FormValue("error") != "" {
		http.Redirect(rw, req, pushFailureURL("denied"), 302)
		return
	}
	id := req.FormValue("state")
	s := pc.GetByB64(id)
	if id == "" || s == nil {
		http.Redirect(rw, req, pushFailureURL("nostate"), 302)
		return
	}
	code := req.FormValue("code")
	if code == "" {
		http.Redirect(rw, req, pushFailureURL("notoken"), 302)
		return
	}
	tok, err := push.Exchange(code)
	if err != nil {
		logging.Error("Failed to get access token for %s: %v", s.Nick, err)
		http.Redirect(rw, req, pushFailureURL("exchange"), 302)
		return
	}

	s.Token = tok
	pc.SetState(s)
	http.Redirect(rw, req, pushDeviceURL(id), 302)
}
开发者ID:gundalow,项目名称:sp0rkle,代码行数:31,代码来源:pushbullet.go


示例7: dumpBans

func (p *Plugin) dumpBans(target string) {
	num := 0

	// Fetch ban list
	banlist, err := p.mode.Bans(target)
	if err != nil {
		logging.Warn("Could not fetch ban list, old bans won't get handled")
		return
	}

	tbmgr := p.ensureTemporaryBanManager(target)

	// Save only bans from us
	for _, ban := range banlist {
		if ban.Nick != p.bot.Me().Nick {
			// Not a ban from us (going by the nickname at least)
			isOldHostmask := false
			for _, hostmask := range p.OldHostmasks {
				// TODO - Test this implementation
				hostmask = regexp.QuoteMeta(hostmask)
				hostmask = strings.Replace(hostmask, "\\*", ".*", -1)
				hostmask = strings.Replace(hostmask, "\\?", ".?", -1)
				if matched, err := regexp.MatchString(hostmask, ban.Src); matched {
					isOldHostmask = true
					break
				} else if err != nil {
					logging.Error("vpnbot.Plugin: dumpBans regular expression failed: %v",
						err)
					break
				}
			}
			if !isOldHostmask {
				// Not a ban from an old hostmask either
				continue
			}
		}

		if _, ok := tbmgr.Get(ban.Hostmask); ok {
			// We already have this ban saved
			continue
		}

		if err := tbmgr.Add(NewTemporaryBan(
			ban.Nick,
			ban.Hostmask,
			ban.Src,
			"Migrated old ban",
			48*time.Hour+ban.Timestamp.Sub(time.Now()))); err != nil {
			logging.Warn("Could not migrate ban on %v: %v", ban.Hostmask, err)
		}

		num++
	}

	if num > 0 {
		p.syncBans(target)
		logging.Info("Migrated %v bans", num)
	}
}
开发者ID:icedream,项目名称:vpnbot,代码行数:59,代码来源:plugin.go


示例8: get

func (ns *namespace) get(key string) interface{} {
	var e Entry
	if err := ns.Get(ns.K(key), &e); err != nil && err != mgo.ErrNotFound && err != boltdb.ErrTxNotWritable {
		logging.Error("Couldn't get config entry for ns=%q key=%q: %v", ns.ns, key, err)
		return nil
	}
	return e.Value
}
开发者ID:fluffle,项目名称:sp0rkle,代码行数:8,代码来源:namespace.go


示例9: delNick

func (st *stateTracker) delNick(nk *Nick) {
	if nk == st.me {
		// Shouldn't get here => internal state tracking code is fubar.
		logging.Error("Tracker.DelNick(): TRYING TO DELETE ME :-(")
		return
	}
	delete(st.nicks, nk.Nick)
	for ch, _ := range nk.chans {
		nk.delChannel(ch)
		ch.delNick(nk)
		if len(ch.nicks) == 0 {
			// Deleting a nick from tracking shouldn't empty any channels as
			// *we* should be on the channel with them to be tracking them.
			logging.Error("Tracker.delNick(): deleting nick %s emptied "+
				"channel %s, this shouldn't happen!", nk.Nick, ch.Name)
		}
	}
}
开发者ID:Kovensky,项目名称:go-lastfm-bot,代码行数:18,代码来源:tracker.go


示例10: Migrate

func Migrate() error {
	ms.Lock()
	defer ms.Unlock()
	ms.db.Init(Bolt, COLLECTION, nil)

	failed := []string{}
	for coll, m := range ms.migrators {
		if m.migrated {
			continue
		}
		logging.Debug("Migrating %q.", coll)
		if err := m.Migrate(); err != nil {
			logging.Error("Migrating %q failed: %v", coll, err)
			failed = append(failed, coll)
			continue
		}
		if differ, ok := m.Migrator.(Differ); ok {
			before, after, err := differ.Diff()
			if err != nil {
				logging.Error("Diffing %q failed: %v", coll, err)
				failed = append(failed, coll)
				continue
			}
			sort.Strings(before)
			sort.Strings(after)
			unified, err := diff.Unified(before, after)
			if err != nil {
				logging.Error("Migration diff: %v\n%s", err, strings.Join(unified, "\n"))
				failed = append(failed, coll)
				continue
			}
		}
		if err := ms.db.Put(K{{"collection", coll}}, &done{true}); err != nil {
			logging.Warn("Setting migrated status for %q: %v", coll, err)
		}
		m.migrated = true
	}
	if len(failed) > 0 {
		return fmt.Errorf("migration failed for: \"%s\"",
			strings.Join(failed, "\", \""))
	}
	return nil
}
开发者ID:fluffle,项目名称:sp0rkle,代码行数:43,代码来源:migration.go


示例11: pushDeviceHTTP

func pushDeviceHTTP(rw http.ResponseWriter, req *http.Request) {
	if err := req.ParseForm(); err != nil {
		http.Redirect(rw, req, pushFailureURL("parse"), 302)
		return
	}
	id := req.FormValue("state")
	s := pc.GetByB64(id)
	if id == "" || s == nil {
		http.Redirect(rw, req, pushFailureURL("nostate"), 302)
		return
	}
	if req.Method == "POST" {
		if s.Iden = req.FormValue("iden"); s.Iden == "" {
			http.Redirect(rw, req, pushFailureURL("noiden"), 302)
			return
		}
		s.Pin = fmt.Sprintf("%06x", rand.Intn(1e6))
		if err := push.Confirm(s); err != nil {
			logging.Error("Failed to send confirmation push for %s: %v", s.Nick, err)
			http.Redirect(rw, req, pushFailureURL("push"), 302)
			return
		}
		pc.SetState(s)
		http.Redirect(rw, req, pushSuccessURL(), 302)
		return
	}
	// get device list and print a form
	devs, err := push.GetDevices(s)
	if err != nil {
		logging.Error("Failed to get devices for %s: %v", s.Nick, err)
		http.Redirect(rw, req, pushFailureURL("device"), 302)
		return
	}
	if len(devs) == 0 {
		strings.NewReader(pushNoDeviceHTML).WriteTo(rw)
		return
	}
	if err = pushDeviceTmpl.Execute(rw, &pushDevice{id, devs}); err != nil {
		logging.Error("Template execution failed: %v", err)
		// assuming here that failure occurred because we couldn't write
		return
	}
}
开发者ID:gundalow,项目名称:sp0rkle,代码行数:43,代码来源:pushbullet.go


示例12: Init

func Init() *Collection {
	pc := &Collection{db.Init().C(COLLECTION)}
	if err := pc.EnsureIndex(mgo.Index{
		Key:    []string{"nick"},
		Unique: true,
	}); err != nil {
		logging.Error("Couldn't create an index on push: %s", err)
	}
	return pc
}
开发者ID:gundalow,项目名称:sp0rkle,代码行数:10,代码来源:push.go


示例13: write

// Write a \r\n terminated line of output to the connected server,
// using Hybrid's algorithm to rate limit if conn.cfg.Flood is false.
func (conn *Conn) write(line string) {
	if !conn.cfg.Flood {
		if t := conn.rateLimit(len(line)); t != 0 {
			// sleep for the current line's time value before sending it
			logging.Info("irc.rateLimit(): Flood! Sleeping for %.2f secs.",
				t.Seconds())
			<-time.After(t)
		}
	}

	if _, err := conn.io.WriteString(line + "\r\n"); err != nil {
		logging.Error("irc.send(): %s", err.Error())
		conn.shutdown()
		return
	}
	if err := conn.io.Flush(); err != nil {
		logging.Error("irc.send(): %s", err.Error())
		conn.shutdown()
		return
	}
	logging.Debug("-> %s", line)
}
开发者ID:Kovensky,项目名称:go-lastfm-bot,代码行数:24,代码来源:connection.go


示例14: isAdmin

func (plugin *Plugin) isAdmin(mask string) bool {
	for _, adminmask := range plugin.Admins {
		// TODO - Test this implementation
		adminmask = regexp.QuoteMeta(adminmask)
		adminmask = strings.Replace(adminmask, "\\*", ".*", -1)
		adminmask = strings.Replace(adminmask, "\\?", ".?", -1)
		if matched, err := regexp.MatchString(adminmask, mask); matched {
			return true
		} else if err != nil {
			logging.Error("vpnbot.Plugin: isAdmin regular expression failed: %v",
				err)
			break
		}
	}

	return false
}
开发者ID:icedream,项目名称:vpnbot,代码行数:17,代码来源:plugin.go


示例15: send

// send is started as a goroutine after a connection is established.
// It shuttles data from the output channel to write(), and is killed
// when Conn.die is closed.
func (conn *Conn) send() {
	for {
		select {
		case line := <-conn.out:
			if err := conn.write(line); err != nil {
				logging.Error("irc.send(): %s", err.Error())
				// We can't defer this, because shutdown() waits for it.
				conn.wg.Done()
				conn.shutdown()
				return
			}
		case <-conn.die:
			// control channel closed, bail out
			conn.wg.Done()
			return
		}
	}
}
开发者ID:scrapbird,项目名称:goirc,代码行数:21,代码来源:connection.go


示例16: Client

func Client(cfg *Config) *Conn {
	if cfg == nil {
		cfg = NewConfig("__idiot__")
	}
	if cfg.Me == nil || cfg.Me.Nick == "" || cfg.Me.Ident == "" {
		cfg.Me = state.NewNick("__idiot__")
		cfg.Me.Ident = "goirc"
		cfg.Me.Name = "Powered by GoIRC"
	}

	dialer := new(net.Dialer)
	if cfg.LocalAddr != "" {
		if !hasPort(cfg.LocalAddr) {
			cfg.LocalAddr += ":0"
		}

		local, err := net.ResolveTCPAddr("tcp", cfg.LocalAddr)
		if err == nil {
			dialer.LocalAddr = local
		} else {
			logging.Error("irc.Client(): Cannot resolve local address %s: %s", cfg.LocalAddr, err)
		}
	}

	conn := &Conn{
		cfg:         cfg,
		dialer:      dialer,
		in:          make(chan *Line, 32),
		out:         make(chan string, 32),
		intHandlers: handlerSet(),
		fgHandlers:  handlerSet(),
		bgHandlers:  handlerSet(),
		stRemovers:  make([]Remover, 0, len(stHandlers)),
		lastsent:    time.Now(),
	}
	conn.addIntHandlers()
	conn.initialise()
	return conn
}
开发者ID:Kovensky,项目名称:go-lastfm-bot,代码行数:39,代码来源:connection.go


示例17: recv

// receive one \r\n terminated line from peer, parse and dispatch it
func (conn *Conn) recv() {
	for {
		s, err := conn.io.ReadString('\n')
		if err != nil {
			if err != io.EOF {
				logging.Error("irc.recv(): %s", err.Error())
			}
			// We can't defer this, because shutdown() waits for it.
			conn.wg.Done()
			conn.shutdown()
			return
		}
		s = strings.Trim(s, "\r\n")
		logging.Debug("<- %s", s)

		if line := ParseLine(s); line != nil {
			line.Time = time.Now()
			conn.in <- line
		} else {
			logging.Warn("irc.recv(): problems parsing line:\n  %s", s)
		}
	}
}
开发者ID:Kovensky,项目名称:go-lastfm-bot,代码行数:24,代码来源:connection.go


示例18: mongoIndexes

func mongoIndexes(c db.Collection) {
	err := c.Mongo().EnsureIndex(mgo.Index{Key: []string{"ns", "key"}, Unique: true})
	if err != nil {
		logging.Error("Couldn't create index on sp0rkle.conf: %s", err)
	}
}
开发者ID:fluffle,项目名称:sp0rkle,代码行数:6,代码来源:config.go


示例19: LogPanic

func (conn *Conn) LogPanic(line *Line) {
	if err := recover(); err != nil {
		_, f, l, _ := runtime.Caller(2)
		logging.Error("%s:%d: panic: %v", f, l, err)
	}
}
开发者ID:StalkR,项目名称:goirc,代码行数:6,代码来源:dispatch.go


示例20: main

// The main program logic.
func main() {
	// Load configuration path from flags
	flag.Parse()

	// Initialize the logger
	logger = glogging.GLogger{}
	logging.SetLogger(logger)

	// Check if we're supposed to generate a default config
	if *generateDefault {
		logger.Debug("Saving default configuration...")
		if err := defaultConfiguration.Save(*configPath); err != nil {
			logger.Error("Failed at saving default configuration: %v", err)
			os.Exit(1)
		}
		logger.Info("Saved default configuration.")
		os.Exit(0)
	}

	// Check if we're supposed to migrate an old config
	if *migratePath != "" {
		logger.Debug("Migrating old configuration...")
		if c, err := LoadV1Config(*migratePath); err != nil {
			logger.Error("Failed to load old configuration: %v", err)
			os.Exit(1)
		} else {
			newC := c.Migrate()
			if err := newC.Save(*configPath); err != nil {
				logger.Error("Migration failed: %v", err)
				os.Exit(1)
			}
			if err := newC.Validate(); err != nil {
				logger.Warn("Migration successful but found errors while "+
					"validating the new configuration, you should fix this before "+
					"running the bot: %v", err)
				os.Exit(2)
			}
		}
		logger.Info("Migration successful.")
		os.Exit(0)
	}

	// Load configuration from configuration path
	if c, err := Load(*configPath); err != nil {
		logger.Error("Can't load configuration from %v: %v\n", *configPath, err)
		os.Exit(1)
	} else {
		loadedConfiguration = c
	}

	logger.Debug("Loaded configuration will be printed below.")
	logger.Debug("%#v", loadedConfiguration)

	// Validate configuration
	if err := loadedConfiguration.Validate(); err != nil {
		logger.Error("The configuration is invalid: %v\n", err)
		os.Exit(2)
	}

	// Now initialize the bot
	logger.Info("Initializing vpnbot %v...", version)
	b := bot.NewBot(
		loadedConfiguration.Server.Address,
		loadedConfiguration.Server.SSL,
		loadedConfiguration.Nick,
		loadedConfiguration.Ident,
		[]string{})
	b.Conn().Config().Version = fmt.Sprintf("vpnbot/%v", version)
	b.Conn().Config().Recover = func(conn *client.Conn, line *client.Line) {
		if err := recover(); err != nil {
			logging.Error("An internal error occurred: %v\n%v",
				err, string(debug.Stack()))
		}
	}
	b.Conn().Config().Pass = loadedConfiguration.Server.Password
	if loadedConfiguration.Name != "" {
		b.Conn().Config().Me.Name = loadedConfiguration.Name
	}

	// Load plugins
	// TODO - Move this into its own little intelligent loader struct, maybe.
	isupportPlugin := isupport.Register(b)
	modePlugin := mode.Register(b, isupportPlugin)
	nickservPlugin := nickserv.Register(b, modePlugin)
	nickservPlugin.Username = loadedConfiguration.NickServ.Username
	nickservPlugin.Password = loadedConfiguration.NickServ.Password
	nickservPlugin.Channels = loadedConfiguration.Channels

	switch {
	case *makeTempBans: // Run in tempban dumping mode
		// Prepare channels to let us know about dumped bans
		doneChan := make(map[string]chan interface{})
		for _, channel := range loadedConfiguration.Channels {
			doneChan[strings.ToLower(channel)] = make(chan interface{}, 1)
		}

		// Load the tempban dumping plugin
		dumptempbanPlugin := dumptempban.Register(b, isupportPlugin, modePlugin)
		dumptempbanPlugin.DumpedBansFunc = func(target string, num int, err error) {
//.........这里部分代码省略.........
开发者ID:icedream,项目名称:vpnbot,代码行数:101,代码来源:main.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang logging.Info函数代码示例发布时间:2022-05-23
下一篇:
Golang logging.Debug函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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