本文整理匯總了Golang中github.com/fluffle/golog/logging.Error函數的典型用法代碼示例。如果您正苦於以下問題:Golang Error函數的具體用法?Golang Error怎麽用?Golang Error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Error函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例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)
}
}
}
示例3: githubWatcher
func githubWatcher(ctx *bot.Context) {
// Watch #sp0rklf for IRC messages about issues coming from github.
if ctx.Nick != "fluffle\\sp0rkle" || ctx.Target() != "#sp0rklf" ||
!strings.Contains(ctx.Text(), "issue #") {
return
}
text := util.RemoveColours(ctx.Text()) // srsly github why colours :(
l := &util.Lexer{Input: text}
l.Find(' ')
text = text[l.Pos()+1:]
l.Find('#')
l.Next()
issue := int(l.Number())
labels, _, err := gh.Issues.ListLabelsByIssue(
githubUser, githubRepo, issue, &github.ListOptions{})
if err != nil {
logging.Error("Error getting labels for issue %d: %v", issue, err)
return
}
for _, l := range labels {
kv := strings.Split(*l.Name, ":")
if len(kv) == 2 && kv[0] == "nick" {
logging.Debug("Recording tell for %s about issue %d.", kv[1], issue)
r := reminders.NewTell("that "+text, bot.Nick(kv[1]), "github", "")
if err := rc.Insert(r); err != nil {
logging.Error("Error inserting github tell: %v", err)
}
}
}
}
示例4: Add
func (cs *commandSet) Add(cmd Command, prefix string) {
if cmd == nil || prefix == "" {
logging.Error("Can't handle prefix '%s' with command.", prefix)
return
}
cs.Lock()
defer cs.Unlock()
if _, ok := cs.set[prefix]; ok {
logging.Error("Prefix '%s' already registered.", prefix)
return
}
cs.set[prefix] = cmd
}
示例5: Add
func (cs *commandSet) Add(r Runner, prefix string) {
if r == nil || prefix == "" {
logging.Error("Prefix or runner empty when adding command.", prefix)
return
}
cs.Lock()
defer cs.Unlock()
if _, ok := cs.set[prefix]; ok {
logging.Error("Prefix '%s' already registered.", prefix)
return
}
cs.set[prefix] = r
}
示例6: Init
func Init() *Collection {
uc := &Collection{db.Init().C(collection)}
err := uc.EnsureIndex(mgo.Index{Key: []string{"url"}, Unique: true})
if err != nil {
logging.Error("Couldn't create url index on sp0rkle.urls: %s", err)
}
for _, idx := range []string{"cachedas", "shortened"} {
err := uc.EnsureIndex(mgo.Index{Key: []string{idx}})
if err != nil {
logging.Error("Couldn't create %s index on sp0rkle.urls: %s", idx, err)
}
}
return uc
}
示例7: Init
func Init() *Collection {
kc := &Collection{db.Init().C(COLLECTION)}
if err := kc.EnsureIndex(mgo.Index{
Key: []string{"key"},
Unique: true,
}); err != nil {
logging.Error("Couldn't create index on karma.key: %s", err)
}
for _, key := range []string{"score", "votes"} {
if err := kc.EnsureIndexKey(key); err != nil {
logging.Error("Couldn't create index on karma.%s: %s", key, err)
}
}
return kc
}
示例8: checkMatchers
func (m *Module) checkMatchers(regexes map[*regexp.Regexp]v8.V8Function, target string, line string, from string) (responded bool) {
// Activate callback on any matches
for regex, fn := range regexes {
matches := regex.FindStringSubmatch(line)
match, _ := json.Marshal(matches)
if len(matches) > 0 {
responded = true
go func(match string, fn v8.V8Function) {
// Clone a response object
m.response++
m.Context.Eval(`var response` + strconv.Itoa(m.response) + ` = clone(response);`)
// Set response parameters
m.Context.Eval(`response` + strconv.Itoa(m.response) + `.match = ` + match)
m.Context.Eval(`response` + strconv.Itoa(m.response) + `.target = "` + target + `";`)
m.Context.Eval(`response` + strconv.Itoa(m.response) + `.nick = "` + m.Client.Me().Nick + `";
response` + strconv.Itoa(m.response) + `.message = {};
response` + strconv.Itoa(m.response) + `.message.nick = "` + from + `";
response` + strconv.Itoa(m.response) + `.message.text = "` + line + `"`)
_, err := fn.Call(v8.V8Object{`response` + strconv.Itoa(m.response)})
if err != nil {
log.Error("%s\n%s", err, fn)
}
}(string(match), fn)
}
}
return
}
示例9: 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)
}
}
示例10: Init
func Init() {
lock.Lock()
defer lock.Unlock()
if irc != nil {
return
}
if *server == "" {
// Don't call logging.Fatal as we don't want a backtrace in this case
logging.Error("--server option required. \nOptions are:\n")
flag.PrintDefaults()
os.Exit(1)
}
// Configure IRC client
irc = client.SimpleClient(*nick, "boing", "not really sp0rkle")
irc.SSL = *ssl
irc.Flood = true
HandleFunc(bot_connected, "connected")
HandleFunc(bot_disconnected, "disconnected")
// This is a special handler that dispatches commands from the command set
HandleFunc(bot_command, "privmsg")
// This is a special handler that triggers a rebuild and re-exec
HandleFunc(bot_rebuild, "notice")
// This is a special handler that triggers a shutdown and disconnect
HandleFunc(bot_shutdown, "notice")
CommandFunc(bot_help, "help", "If you need to ask, you're beyond help.")
}
示例11: TopTen
func (sc *Collection) TopTen(ch string) []*NickStat {
var res []*NickStat
q := sc.Find(bson.M{"chan": ch}).Sort("-lines").Limit(10)
if err := q.All(&res); err != nil {
logging.Error("TopTen Find error for channel %s: %v", ch, err)
}
return res
}
示例12: Init
func Init() {
bot.Command(urbanDictionary, "ud", "ud <term> -- "+
"Look up <term> on UrbanDictionary.")
mcConf = conf.Ns("mc")
srv := mcConf.String(mcServer)
if srv != "" {
if st, err := pollServer(srv); err == nil {
logging.Info("Starting MC poller for '%s'", srv)
bot.Poll(st)
bot.Handle(func(ctx *bot.Context) {
st.Topic(ctx)
}, "332")
} else {
logging.Error("Not starting MC poller: %v", err)
}
}
bot.Command(mcSet, "mc set", "mc set <key> <value> -- "+
"Set minecraft server polling config vars.")
// TODO(fluffle): Polling can only be en/disabled at reconnect.
// bot.Command(mcPoll, "mc poll", "mc poll start|stop -- "+
// "Enable or disable minecraft server polling.")
if *githubToken != "" {
rc = reminders.Init()
gh = githubClient()
bot.Handle(githubWatcher, client.PRIVMSG)
bot.Command(githubCreateIssue, "file bug:", "file bug: <title>. "+
"<descriptive body> -- Files a bug on GitHub. Abusers will be hurt.")
bot.Command(githubCreateIssue, "file bug", "file bug <title>. "+
"<descriptive body> -- Files a bug on GitHub. Abusers will be hurt.")
bot.Command(githubCreateIssue, "report bug", "report bug <title>. "+
"<descriptive body> -- Files a bug on GitHub. Abusers will be hurt.")
bot.Command(githubUpdateIssue, "update bug #", "update bug #<number> "+
"<comment> -- Adds a comment to bug <number>. Abusers will be hurt.")
}
if push.Enabled() {
pc = pushes.Init()
bot.Command(pushEnable, "push enable", "push enable -- "+
"Start the OAuth flow to enable pushbullet notifications.")
bot.Command(pushDisable, "push disable", "push disable -- "+
"Disable pushbullet notifications and delete tokens.")
bot.Command(pushConfirm, "push auth", "push auth <pin> -- "+
"Confirm pushed PIN to finish pushbullet auth dance.")
bot.Command(pushAddAlias, "push add alias", "push add alias -- "+
"Add a push alias for your nick.")
bot.Command(pushDelAlias, "push del alias", "push del alias -- "+
"Delete a push alias for your nick.")
http.HandleFunc("/oauth/auth", pushAuthHTTP)
http.HandleFunc("/oauth/device", pushDeviceHTTP)
http.HandleFunc("/oauth/success", pushSuccessHTTP)
http.HandleFunc("/oauth/failure", pushFailureHTTP)
}
}
示例13: 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)
}
}
}
示例14: Init
// Wrapper to get hold of a factoid collection handle
func Init() *Collection {
mc := &Collection{db.Mongo.C(COLLECTION).Mongo()}
if err := mc.EnsureIndex(mgo.Index{
Key: []string{"tag", "source", "dest"},
}); err != nil {
logging.Error("Couldn't create an index on markov: %s", err)
}
return mc
}
示例15: TellsFor
func (rc *Collection) TellsFor(nick string) []*Reminder {
nick = strings.ToLower(nick)
q := rc.Find(bson.M{"$and": []bson.M{{"tell": true}, {"to": nick}}})
ret := make([]*Reminder, 0)
if err := q.All(&ret); err != nil {
logging.Error("Loading tells for %s returned error: %v", nick, err)
return nil
}
return ret
}