當前位置: 首頁>>代碼示例>>Golang>>正文


Golang log.Fatal函數代碼示例

本文整理匯總了Golang中github.com/ngaut/log.Fatal函數的典型用法代碼示例。如果您正苦於以下問題:Golang Fatal函數的具體用法?Golang Fatal怎麽用?Golang Fatal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Fatal函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getSuitableBlock

func (b BlockContainer) getSuitableBlock(nodeID uint64, compressedSize int) *Block {
	if nodeID < MinNodeId {
		logger.Fatal("NodeId Error")
	}

	if compressedSize == 0 {
		logger.Fatal("CompressedSize = 0")
	}

	block := b.getBlockByNodeID(nodeID)

	// if block != nil && !block.availableNewSize(uint32(compressedSize)) {
	//     b.evitAndReallocBlock(block)
	// }

	if block == nil {
		for i := 0; i < MaxBlockCount; i++ {
			bl := b.blocks[i]
			if bl.available(uint32(compressedSize)) {
				block = bl
				break
			}
		}
	}

	if block == nil {
		logger.Fatal("Not Found Available Block, Error!!!")
	}

	return block
}
開發者ID:yqingp,項目名稱:lodb,代碼行數:31,代碼來源:block_container.go

示例2: batchRawPut

// blind put bench
func batchRawPut(value []byte) {
	cli, err := tikv.NewRawKVClient(strings.Split(*pdAddr, ","))
	if err != nil {
		log.Fatal(err)
	}

	wg := sync.WaitGroup{}
	base := *dataCnt / *workerCnt
	wg.Add(*workerCnt)
	for i := 0; i < *workerCnt; i++ {
		go func(i int) {
			defer wg.Done()

			for j := 0; j < base; j++ {
				k := base*i + j
				key := fmt.Sprintf("key_%d", k)
				err = cli.Put([]byte(key), value)
				if err != nil {
					log.Fatal(errors.ErrorStack(err))
				}
			}
		}(i)
	}
	wg.Wait()
}
開發者ID:pingcap,項目名稱:tidb,代碼行數:26,代碼來源:main.go

示例3: main

func main() {
	flag.Parse()

	if *lease < 0 {
		log.Fatalf("invalid lease seconds %d", *lease)
	}

	tidb.SetSchemaLease(time.Duration(*lease) * time.Second)

	log.SetLevelByString(*logLevel)
	store, err := tidb.NewStore(fmt.Sprintf("%s://%s", *store, *storePath))
	if err != nil {
		log.Fatal(err)
	}

	var driver relay.IDriver
	driver = relay.NewTiDBDriver(store)
	replayer, err := relay.NewReplayer(driver, *relayPath, *check)
	if err != nil {
		log.Fatal(err)
	}

	replayer.OnRecordRead = func(rec *relay.Record) {
		fmt.Printf("%s\n", rec)
	}

	err = replayer.Run()
	if err != nil {
		log.Fatal(errors.ErrorStack(err))
	}
}
開發者ID:pingcap,項目名稱:mysqlrelay,代碼行數:31,代碼來源:main.go

示例4: doDMLWorks

// Execute DML statements in bootstrap stage.
// All the statements run in a single transaction.
func doDMLWorks(s Session) {
	mustExecute(s, "BEGIN")

	// Insert a default user with empty password.
	mustExecute(s, `INSERT INTO mysql.user VALUES
		("%", "root", "", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y")`)

	// Init global system variables table.
	values := make([]string, 0, len(variable.SysVars))
	for k, v := range variable.SysVars {
		value := fmt.Sprintf(`("%s", "%s")`, strings.ToLower(k), v.Value)
		values = append(values, value)
	}
	sql := fmt.Sprintf("INSERT INTO %s.%s VALUES %s;", mysql.SystemDB, mysql.GlobalVariablesTable,
		strings.Join(values, ", "))
	mustExecute(s, sql)

	sql = fmt.Sprintf(`INSERT INTO %s.%s VALUES("%s", "%s", "Bootstrap flag. Do not delete.")
		ON DUPLICATE KEY UPDATE VARIABLE_VALUE="%s"`,
		mysql.SystemDB, mysql.TiDBTable, bootstrappedVar, bootstrappedVarTrue, bootstrappedVarTrue)
	mustExecute(s, sql)
	_, err := s.Execute("COMMIT")
	if err != nil {
		time.Sleep(1 * time.Second)
		// Check if TiDB is already bootstrapped.
		b, err1 := checkBootstrapped(s)
		if err1 != nil {
			log.Fatal(err1)
		}
		if b {
			return
		}
		log.Fatal(err)
	}
}
開發者ID:yubobo,項目名稱:tidb,代碼行數:37,代碼來源:bootstrap.go

示例5: main

func main() {
	cus, err := nsq.NewConsumer("log", "logxx", nsq.NewConfig())
	if err != nil {
		log.Fatal(err)
	}

	var th = &TailHandler{SouceMap: getSourceMap()}
	go func() {
		t := time.NewTicker(time.Hour)
		for {
			select {
			case <-t.C:
				th.SouceMap = getSourceMap()
			}
		}
	}()

	cus.AddHandler(th)

	if err := cus.ConnectToNSQD(*nsqhost); err != nil {
		log.Fatal(err)
	}

	for {
		select {
		case <-cus.StopChan:
			return
		}
	}

}
開發者ID:qgweb,項目名稱:new,代碼行數:31,代碼來源:logserver.go

示例6: get

func (n *Node) get(key string) (message *Message, err error) {
	index := n.getSuitablePivotIndex(key)
	if index >= int(n.pivotCount) {
		logger.Fatal("Unknow Error, pivot index out range")
	}

	pivot := n.pivots[index]

	if pivot == nil {
		logger.Fatal("Unknow error, Pivot Is Nil, Min pivot count is 1, but current = 0")
	}

	message = pivot.get(key)
	if message != nil {
		return
	}

	if n.isLeaf {
		return
	}

	if pivot.hasChild() {
		childNode := n.tree.nodes[pivot.childNodeID]
		if childNode == nil {
			logger.Debug("Get Node Error")
		}

		message, err = childNode.get(key)
	}

	return
}
開發者ID:yqingp,項目名稱:lodb,代碼行數:32,代碼來源:node.go

示例7: main

func main() {
	pub, err := nsq.NewProducer(*tHost, nsq.NewConfig())
	if err != nil {
		log.Fatal(err)
	}
	t, err := tail.TailFile(*tFile, tail.Config{Follow: true,
		//Location: &tail.SeekInfo{Offset: 0, Whence: os.SEEK_END}})
		Location: &tail.SeekInfo{Offset: 0, Whence: os.SEEK_CUR}})
	if err != nil {
		log.Fatal(err)
	}

	for line := range t.Lines {
		if *tTag != "" {
			for k, tag := range strings.Split(*tTag, "|") {
				var ks = []string{"pv", "click", "other"}
				if strings.Contains(line.Text, tag) {
					if *tDebug == "1" {
						fmt.Println(fmt.Println(line.Text))
					}
					pub.Publish("log", []byte(ks[k]+"\t"+line.Text))
				}
			}
		}
	}
}
開發者ID:qgweb,項目名稱:new,代碼行數:26,代碼來源:logclient.go

示例8: flush

func (h *Header) flush() {
	file := h.tree.file
	buffer := &bytes.Buffer{}
	serializeHeader(buffer, h)

	if _, err := file.WriteAt(buffer.Bytes(), 0); err != nil {
		logger.Fatal(err)
	}

	// h.serializeContainerToDisk()

	buffer = &bytes.Buffer{}
	h.container.writeTo(buffer)

	crcValue := checksum(buffer) // uint32
	crcBuffer := &bytes.Buffer{}

	binary.Write(crcBuffer, binary.LittleEndian, crcValue)
	binary.Write(crcBuffer, binary.LittleEndian, uint32(buffer.Len()))

	if _, err := file.WriteAt(crcBuffer.Bytes(), HeaderSize); err != nil {
		logger.Fatal(err)
	}

	offset := HeaderSize + int64(Uint32Size)*2
	if _, err := file.WriteAt(buffer.Bytes(), offset); err != nil {
		logger.Fatal(err)
	}

	if err := file.Sync(); err != nil {
		logger.Fatal(err)
	}

}
開發者ID:yqingp,項目名稱:lodb,代碼行數:34,代碼來源:header.go

示例9: deserializeBlockContainer

func deserializeBlockContainer(reader *bytes.Reader, blockContainer *BlockContainer) {
	var nodesOffset uint64
	if err := binary.Read(reader, binary.LittleEndian, &nodesOffset); err != nil {
		logger.Fatal(err)
	}

	blockContainer.nodesOffset = nodesOffset

	logger.Debug("Serialize nodesOffset =", nodesOffset)

	var blockCount uint32
	if err := binary.Read(reader, binary.LittleEndian, &blockCount); err != nil {
		logger.Fatal(err)
	}
	blockContainer.blockCount = blockCount

	var blockSize uint64
	if err := binary.Read(reader, binary.LittleEndian, &blockSize); err != nil {
		logger.Fatal(err)
	}
	blockContainer.blockSize = blockSize

	var blockUsedCount uint32
	if err := binary.Read(reader, binary.LittleEndian, &blockUsedCount); err != nil {
		logger.Fatal(err)
	}
	blockContainer.blockUsedCount = blockUsedCount
}
開發者ID:yqingp,項目名稱:lodb,代碼行數:28,代碼來源:serializer.go

示例10: main

func main() {
	tidb.RegisterLocalStore("boltdb", boltdb.Driver{})
	tidb.RegisterStore("tikv", tikv.Driver{})

	metric.RunMetric(3 * time.Second)
	printer.PrintTiDBInfo()
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()

	if *lease < 0 {
		log.Fatalf("invalid lease seconds %d", *lease)
	}

	tidb.SetSchemaLease(time.Duration(*lease) * time.Second)

	cfg := &server.Config{
		Addr:       fmt.Sprintf(":%s", *port),
		LogLevel:   *logLevel,
		StatusAddr: fmt.Sprintf(":%s", *statusPort),
		Socket:     *socket,
	}

	log.SetLevelByString(cfg.LogLevel)
	store, err := tidb.NewStore(fmt.Sprintf("%s://%s", *store, *storePath))
	if err != nil {
		log.Fatal(errors.ErrorStack(err))
	}
	// Create a session to load information schema.
	se, err := tidb.CreateSession(store)
	if err != nil {
		log.Fatal(errors.ErrorStack(err))
	}
	se.Close()

	var driver server.IDriver
	driver = server.NewTiDBDriver(store)
	var svr *server.Server
	svr, err = server.NewServer(cfg, driver)
	if err != nil {
		log.Fatal(errors.ErrorStack(err))
	}

	sc := make(chan os.Signal, 1)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

	go func() {
		sig := <-sc
		log.Infof("Got signal [%d] to exit.", sig)
		svr.Close()
		os.Exit(0)
	}()

	log.Error(svr.Run())
}
開發者ID:anywhy,項目名稱:tidb,代碼行數:59,代碼來源:main.go

示例11: processAction

func (s *Server) processAction(e interface{}) {
	if strings.Index(GetEventPath(e), models.GetProxyPath(s.top.ProductName)) == 0 {
		// proxy event, should be order for me to suicide
		s.handleProxyCommand()
		return
	}

	// re-watch
	nodes, err := s.top.WatchChildren(models.GetWatchActionPath(s.top.ProductName), s.evtbus)
	if err != nil {
		log.Fatal(errors.ErrorStack(err))
	}

	seqs, err := models.ExtraSeqList(nodes)
	if err != nil {
		log.Fatal(errors.ErrorStack(err))
	}

	if len(seqs) == 0 || !s.top.IsChildrenChangedEvent(e) {
		return
	}

	// get last pos
	index := -1
	for i, seq := range seqs {
		if s.lastActionSeq < seq {
			index = i
			break
		}
	}

	if index < 0 {
		return
	}

	actions := seqs[index:]
	for _, seq := range actions {
		exist, err := s.top.Exist(path.Join(s.top.GetActionResponsePath(seq), s.pi.ID))
		if err != nil {
			log.Fatal(errors.ErrorStack(err))
		}

		if exist {
			continue
		}

		if s.checkAndDoTopoChange(seq) {
			s.responseAction(int64(seq))
		}
	}

	s.lastActionSeq = seqs[len(seqs)-1]
}
開發者ID:GavinHwa,項目名稱:reborn,代碼行數:53,代碼來源:router.go

示例12: prepareBenchSession

func prepareBenchSession() Session {
	store, err := NewStore("memory://bench")
	if err != nil {
		log.Fatal(err)
	}
	log.SetLevel(log.LOG_LEVEL_ERROR)
	se, err := CreateSession(store)
	if err != nil {
		log.Fatal(err)
	}
	mustExecute(se, "use test")
	return se
}
開發者ID:yangxuanjia,項目名稱:tidb,代碼行數:13,代碼來源:bench_test.go

示例13: valid

func (p Pivot) valid() bool {
	if p.messageContainer == nil {
		logger.Fatal("Pivot MessageContainer Is Nil")
		return false
	}

	if p.node == nil {
		logger.Fatal("Pivot Node Is Nil")
		return false
	}

	return true
}
開發者ID:yqingp,項目名稱:lodb,代碼行數:13,代碼來源:pivot.go

示例14: readResult

func readResult(rs ast.RecordSet, count int) {
	for count > 0 {
		x, err := rs.Next()
		if err != nil {
			log.Fatal(err)
		}
		if x == nil {
			log.Fatal(count)
		}
		count--
	}
	rs.Close()
}
開發者ID:yangxuanjia,項目名稱:tidb,代碼行數:13,代碼來源:bench_test.go

示例15: fatal

func fatal(msg interface{}) {
	if globalConn != nil {
		globalConn.Close()
	}

	// cleanup
	switch msg.(type) {
	case string:
		log.Fatal(msg)
	case error:
		log.Fatal(errors.ErrorStack(msg.(error)))
	}
}
開發者ID:vebin,項目名稱:reborn,代碼行數:13,代碼來源:main.go


注:本文中的github.com/ngaut/log.Fatal函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。