本文整理汇总了Golang中gopkg/in/inconshreveable/log15/v2.Logger.Error方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Error方法的具体用法?Golang Logger.Error怎么用?Golang Logger.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/inconshreveable/log15/v2.Logger
的用法示例。
在下文中一共展示了Logger.Error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: updateIssueReviewLabels
func updateIssueReviewLabels(client *github.Client, log log15.Logger, review ReviewRequest) error {
oldLabels := []string{}
newLabels := []string{review.CalculateAppropriateStatus()}
foundReviewLabel, incorrectReviewLabel := false, false
for _, l := range review.issue.Labels {
oldLabels = append(oldLabels, *l.Name)
switch *l.Name {
case WIPLabel, CakedLabel, AwaitingCakeLabel:
foundReviewLabel = true
if *l.Name != newLabels[0] {
incorrectReviewLabel = true
}
continue
default:
newLabels = append(newLabels, *l.Name)
}
}
var labelsNeedUpdating bool
switch {
case !foundReviewLabel:
labelsNeedUpdating = true
log.Info("could not find review label", "old_labels", oldLabels, "new_labels", newLabels)
case incorrectReviewLabel:
labelsNeedUpdating = true
log.Info("review label is incorrect", "old_labels", oldLabels, "new_labels", newLabels)
default:
log.Info("review label does not need updating", "labels", oldLabels)
}
if labelsNeedUpdating {
_, _, err := client.Issues.ReplaceLabelsForIssue(*review.repo.Owner.Login, *review.repo.Name, review.Number(), newLabels)
if err != nil {
log.Error("unable to update issue review label", "err", err)
return err
}
}
return nil
}
示例2: NewRaft
// NewRaft returns a new raft struct based on the provided configuration
func NewRaft(config *Config, logger log.Logger) (*Raft, error) {
rand.Seed(time.Now().Unix())
if config.StateMachine == nil {
return nil, fmt.Errorf("No state machine configured.")
}
inbox := make(chan *channelCmd, 4096)
// set advertise address, if set
advertise := config.Bind
if len(config.Advertise) > 0 {
advertise = config.Advertise
}
logger = logger.New("module", "raft", "server", advertise)
// cleanup old directories
if len(config.Peers) != 0 {
err := os.RemoveAll(config.BaseDir)
if err != nil {
return nil, err
}
}
// create basic directories
err := os.MkdirAll(config.BaseDir, os.FileMode(0700))
err = createDirs(config.BaseDir)
if err != nil {
logger.Error("Can not create directories", "error", err.Error())
return nil, err
}
// create stable
stable, err := newBoltDBStable(fmt.Sprintf("%s/logs", config.BaseDir), logger)
raftRPCImpl := newRaftRPC(logger, inbox)
// create raft rpc server
rpcServer, err := multiserver.NewRPCServer(config.Bind, codecFunc, raftRPCImpl, config.TLSConfig, logger)
if err != nil {
logger.Error("Can not create rpc server", "error", err.Error())
return nil, err
}
client := NewClient(config.ClientTLSConfig)
// create peer list without itself
// at the moment the config is static
// and needs restart for changes
peers := make(map[string]*peer)
for _, server := range config.Peers {
// check if this instance is in the list
if server != advertise {
p := &peer{
addr: server,
timeoutCh: make(chan bool),
syncing: false,
}
peers[server] = p
}
}
chMap := &channelMap{
responseWaiter: make(map[uint64]chan interface{}),
responseResult: make(map[uint64]interface{}),
}
vRaft := &Raft{
peers: peers,
state: Shutdown,
client: client,
appendResCh: make(chan *ResponseAppendEntry, 4096),
commitCh: make(chan uint64, 4096),
inbox: inbox,
config: config,
channelMap: chMap,
stable: stable,
logger: logger,
advertise: advertise,
rpcServer: rpcServer,
bind: config.Bind,
fsm: config.StateMachine,
voteRespCh: make(chan *ResponseVote, len(peers)),
commandCh: make(chan *channelCmd, 4096),
leaderCh: make(chan string, 5),
raftRPC: raftRPCImpl,
}
vRaft.workingSnapshot = &fsmSnapshot{
LastIndex: 0,
LastTerm: 0,
}
return vRaft, nil
}