本文整理汇总了Golang中github.com/purstal/go-tieba-base/logs.Logger.Error方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Error方法的具体用法?Golang Logger.Error怎么用?Golang Logger.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/purstal/go-tieba-base/logs.Logger
的用法示例。
在下文中一共展示了Logger.Error方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newStrKwManager
func newStrKwManager(fileName string, logger *logs.Logger) *kw_manager.StringKeywordManager {
var m *kw_manager.StringKeywordManager
var err error
if fileName != "" {
m, err =
kw_manager.NewStringKeywordManagerBidingWithFile(
fileName, time.Second, logger)
if err != nil {
logger.Error("无法创建string关键词管理.", err)
panic(err)
}
return m
} else {
logger.Warn("未设置string关键词文件")
return kw_manager.NewStringKeywordManager(logger)
}
}
示例2: NewMessageMonitor
func NewMessageMonitor(logger *logs.Logger, interval time.Duration, acc *postbar.Account, lastFoundPid uint64) *MessageMonitor {
var monitor MessageMonitor
monitor.Interval = interval
monitor.MessageChan = make(chan message.ReplyMessage)
monitor.actChan = make(chan action.Action)
go func() {
ticker := time.NewTicker(monitor.Interval)
for {
msgs, _lastFoundPid, err, pberr := checkReply(acc, lastFoundPid)
if len(msgs) > 0 {
if err != nil {
logger.Error("无法获取消息提醒", err)
continue
} else if pberr != nil && pberr.ErrorCode != 0 {
logger.Error("无法获取消息提醒", pberr)
continue
}
lastFoundPid = _lastFoundPid
for _, msg := range msgs {
monitor.MessageChan <- msg
}
}
select {
case <-ticker.C:
case act := <-monitor.actChan:
switch act.Pattern {
case Stop:
ticker.Stop()
//logs.Debug("喵")
close(monitor.MessageChan)
//logs.Debug("喵喵")
close(monitor.actChan)
//logs.Debug("将解引赋值:", lastFoundPid)
*(act.Param.(*chan uint64)) <- lastFoundPid
return
}
}
}
}()
return &monitor
}
示例3: NewRegexpKeywordManagerBidingWithFile
func NewRegexpKeywordManagerBidingWithFile(keyWordFileFlieName string,
checkInterval time.Duration, logger *logs.Logger) (*RegexpKeywordManager, error) {
var m RegexpKeywordManager
m.FileName = keyWordFileFlieName
file, err := os.Open(m.FileName)
if os.IsNotExist(err) {
var err error
file, err = os.Create(m.FileName)
if err != nil {
return nil, err
}
} else if err != nil {
return nil, err
} else {
err := LoadExps(file, &m.KewWordExps, logger)
if err != nil {
return nil, err
}
}
if fi, err := file.Stat(); err != nil {
return nil, err
} else {
m.LastModTime = fi.ModTime()
}
file.Close()
m.CheckInterval = checkInterval
m.actChan = make(chan action.Action)
go func() {
ticker := time.NewTicker(m.CheckInterval)
for {
select {
case <-ticker.C:
case act := <-m.actChan:
switch act.Pattern {
case ChangeInterval:
ticker.Stop()
ticker = time.NewTicker(act.Param.(time.Duration))
case ChangeFile:
}
continue
}
file, err1 := os.Open(m.FileName)
if err1 != nil {
logger.Error("无法打开关键词文件,跳过本次.", err1, ".")
continue
}
func() {
defer func() { file.Close() }()
fi, err2 := file.Stat()
if err2 != nil {
logger.Error("无法获取文件信息,跳过本次.", err2, ".")
return
}
if modTime := fi.ModTime(); modTime != m.LastModTime {
err := LoadExps(file, &m.KewWordExps, logger)
if err != nil {
logger.Error("无法更新关键词,下次修改前将不尝试读取.", err, ".")
}
m.LastModTime = modTime
}
}()
}
}()
return &m, nil
}