本文整理匯總了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
}