当前位置: 首页>>代码示例>>Golang>>正文


Golang Logger.Error方法代码示例

本文整理汇总了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
}
开发者ID:timothee-alby,项目名称:cake-bot,代码行数:47,代码来源:issues.go

示例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
}
开发者ID:sisatech,项目名称:raft,代码行数:99,代码来源:raft.go


注:本文中的gopkg/in/inconshreveable/log15/v2.Logger.Error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。