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


Golang log.Info函數代碼示例

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


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

示例1: Open

// Open opens or creates a storage with specific format for a local engine Driver.
func (d Driver) Open(schema string) (kv.Storage, error) {
	mc.mu.Lock()
	defer mc.mu.Unlock()

	if store, ok := mc.cache[schema]; ok {
		// TODO: check the cache store has the same engine with this Driver.
		log.Info("cache store", schema)
		return store, nil
	}

	db, err := d.Driver.Open(schema)
	if err != nil {
		return nil, errors.Trace(err)
	}

	log.Info("New store", schema)
	s := &dbStore{
		txns:       make(map[uint64]*dbTxn),
		keysLocked: make(map[string]uint64),
		uuid:       uuid.NewV4().String(),
		path:       schema,
		db:         db,
		compactor:  newLocalCompactor(localCompactDefaultPolicy, db),
	}
	mc.cache[schema] = s
	s.compactor.Start()
	return s, nil
}
開發者ID:stumaxim28,項目名稱:tidb,代碼行數:29,代碼來源:kv.go

示例2: TestGetPut

func (s *HBasePutTestSuit) TestGetPut(c *C) {
	log.Info(codec.EncodeKey(170))

	p := NewPut([]byte("1_\xff\xff"))
	p2 := NewPut([]byte("1_\xff\xfe"))
	p3 := NewPut([]byte("1_\xff\xee"))
	p.AddValue([]byte("cf"), []byte("q"), []byte("!"))
	p2.AddValue([]byte("cf"), []byte("q"), []byte("!"))
	p3.AddValue([]byte("cf"), []byte("q"), []byte("!"))

	cli, err := NewClient(getTestZkHosts(), "/hbase")
	c.Assert(err, Equals, nil)

	cli.Put("t2", p)
	cli.Put("t2", p2)
	cli.Put("t2", p3)

	scan := NewScan([]byte("t2"), 100, cli)
	scan.StartRow = []byte("1_")
	for {
		r := scan.Next()
		if r == nil {
			break
		}
		log.Info(r.SortedColumns[0].Row)
	}

	cli.Delete("t2", NewDelete([]byte("1_\xff\xff")))
	cli.Delete("t2", NewDelete([]byte("1_\xff\xfe")))
	cli.Delete("t2", NewDelete([]byte("1_\xff\xee")))

}
開發者ID:yzl11,項目名稱:vessel,代碼行數:32,代碼來源:put_test.go

示例3: TestNewAction

func (s *testModelSuite) TestNewAction(c *C) {
	log.Info("[TestNewAction][start]")
	fakeCoordConn := zkhelper.NewConn()

	err := NewAction(fakeCoordConn, productName, ACTION_TYPE_SLOT_CHANGED, nil, "desc", false)
	c.Assert(err, IsNil)

	prefix := GetWatchActionPath(productName)
	exist, _, err := fakeCoordConn.Exists(prefix)
	c.Assert(exist, Equals, true)
	c.Assert(err, IsNil)

	// test if response node exists
	d, _, err := fakeCoordConn.Get(prefix + "/0000000001")
	c.Assert(err, IsNil)

	// test get action data
	d, _, err = fakeCoordConn.Get(GetActionResponsePath(productName) + "/0000000001")
	c.Assert(err, IsNil)

	var action Action
	json.Unmarshal(d, &action)
	c.Assert(action.Desc, Equals, "desc")
	c.Assert(action.Type, Equals, ACTION_TYPE_SLOT_CHANGED)

	fakeCoordConn.Close()
	log.Info("[TestNewAction][end]")
}
開發者ID:XMAN-WOMBAT,項目名稱:reborn,代碼行數:28,代碼來源:action_test.go

示例4: BulkInsertData

func BulkInsertData(reader *bufio.Reader, ktype string) {
	bk := es.Bulk()
	num := 0
	for {
		line, err := reader.ReadString('\n')
		if err == io.EOF {
			break
		}
		info := strings.Split(line, "\t#\t")
		log.Info(len(info))
		if len(info) != 2 {
			continue
		}
		ad, ua := getAdUa(info[0], "\t")
		keyword := getKeyWord(info[1], "\t")
		lonlat := GetLonLat(ad)
		if lonlat == "" {
			continue
		}
		num++
		id := encrypt.DefaultMd5.Encode("1456185600" + ad + ua)
		pinfo := map[string]interface{}{
			"ad":  ad,
			"ua":  ua,
			ktype: keyword,
			"geo": lonlat,
		}
		bk.Add(elastic.NewBulkUpdateRequest().Index("map_trace").Type("map").Doc(pinfo).Id(id).DocAsUpsert(true))
		bk.Add(elastic.NewBulkUpdateRequest().Index("map_trace_search").Type("map").Doc(pinfo).Id(id).DocAsUpsert(true))
		if num%10000 == 0 {
			log.Error(bk.Do())
		}
	}
	log.Info(bk.Do())
}
開發者ID:qgweb,項目名稱:new,代碼行數:35,代碼來源:import.go

示例5: checkExpiredKeysWorker

func (gc *localstoreCompactor) checkExpiredKeysWorker() {
	gc.workerWaitGroup.Add(1)
	defer gc.workerWaitGroup.Done()
	for {
		select {
		case <-gc.stopCh:
			log.Info("GC stopped")
			return
		case <-gc.ticker.C:
			gc.mu.Lock()
			m := gc.recentKeys
			if len(m) == 0 {
				gc.mu.Unlock()
				continue
			}
			gc.recentKeys = make(map[string]struct{})
			gc.mu.Unlock()
			log.Info("GC trigger")
			for k := range m {
				err := gc.Compact(nil, []byte(k))
				if err != nil {
					log.Error(err)
				}
			}
		}
	}
}
開發者ID:netroby,項目名稱:tidb,代碼行數:27,代碼來源:compactor.go

示例6: DB

func (c *Cluster) DB(isread bool) (*mysql.DB, error) {
	if isread {
		log.Info("return a master conn")
		return c.Master()
	}

	log.Info("return a slave conn")
	return c.Slave()
}
開發者ID:bytedance,項目名稱:dbatman,代碼行數:9,代碼來源:driver.go

示例7: Create

func (e *etcdImpl) Create(wholekey string, value []byte, flags int32, aclv []zk.ACL) (keyCreated string, err error) {
	seq := (flags & zk.FlagSequence) != 0
	tmp := (flags & zk.FlagEphemeral) != 0
	ttl := uint64(MAX_TTL)
	if tmp {
		ttl = 5
	}

	var resp *etcd.Response

	conn, err := e.pool.Get()
	if err != nil {
		return "", err
	}

	defer e.pool.Put(conn)
	c := conn.(*PooledEtcdClient).c

	fn := c.Create
	log.Info("create", wholekey)

	if seq {
		wholekey = path.Dir(wholekey)
		fn = c.CreateInOrder
	} else {
		for _, v := range aclv {
			if v.Perms == PERM_DIRECTORY {
				log.Info("etcdImpl:create directory", wholekey)
				fn = nil
				resp, err = c.CreateDir(wholekey, uint64(ttl))
				if err != nil {
					return "", convertToZkError(err)
				}
			}
		}
	}

	if fn == nil {
		if tmp {
			e.keepAlive(wholekey, ttl)
		}
		return resp.Node.Key, nil
	}

	resp, err = fn(wholekey, string(value), uint64(ttl))
	if err != nil {
		return "", convertToZkError(err)
	}

	if tmp {
		e.keepAlive(resp.Node.Key, ttl)
	}

	return resp.Node.Key, nil
}
開發者ID:Goyoo,項目名稱:codis-docker,代碼行數:55,代碼來源:etcd.go

示例8: Push

// Push metircs in background.
func Push(cfg *MetricConfig) {
	if cfg.PushInterval.Duration == zeroDuration || len(cfg.PushAddress) == 0 {
		log.Info("disable Prometheus push client")
		return
	}

	log.Info("start Prometheus push client")

	interval := cfg.PushInterval.Duration
	go prometheusPushClient(cfg.PushJob, cfg.PushAddress, interval)
}
開發者ID:pingcap,項目名稱:tidb,代碼行數:12,代碼來源:metricutil.go

示例9: NewCookiePut

func NewCookiePut() *CookiePut {
	var zj = &CookiePut{}
	zj.kf = dbfactory.NewKVFile(fmt.Sprintf("./%s.txt", convert.ToString(time.Now().Unix())))
	zj.putTags = make(map[string]map[string]int)
	zj.Timestamp = timestamp.GetHourTimestamp(-1)
	zj.initPutAdverts()
	zj.initPutTags("TAGS_5*", "cookie_", "")
	log.Info(zj.putAdverts)
	log.Info(zj.putTags)
	return zj
}
開發者ID:qgweb,項目名稱:new,代碼行數:11,代碼來源:ck.go

示例10: Rebalance

// experimental simple auto rebalance :)
func Rebalance(coordConn zkhelper.Conn, delay int) error {
	targetQuota, err := getQuotaMap(coordConn)
	if err != nil {
		return errors.Trace(err)
	}
	livingNodes, err := getLivingNodeInfos(coordConn)
	if err != nil {
		return errors.Trace(err)
	}
	log.Info("start rebalance")
	for _, node := range livingNodes {
		for len(node.CurSlots) > targetQuota[node.GroupId] {
			for _, dest := range livingNodes {
				if dest.GroupId != node.GroupId && len(dest.CurSlots) < targetQuota[dest.GroupId] {
					slot := node.CurSlots[len(node.CurSlots)-1]
					// create a migration task
					t := NewMigrateTask(MigrateTaskInfo{
						Delay:      delay,
						FromSlot:   slot,
						ToSlot:     slot,
						NewGroupId: dest.GroupId,
						Status:     MIGRATE_TASK_MIGRATING,
						CreateAt:   strconv.FormatInt(time.Now().Unix(), 10),
					})
					u, err := uuid.NewV4()
					if err != nil {
						return errors.Trace(err)
					}
					t.Id = u.String()

					if ok, err := preMigrateCheck(t); ok {
						// do migrate
						err := t.run()
						if err != nil {
							log.Warning(err)
							return errors.Trace(err)
						}
					} else {
						log.Warning(err)
						return errors.Trace(err)
					}
					node.CurSlots = node.CurSlots[0 : len(node.CurSlots)-1]
					dest.CurSlots = append(dest.CurSlots, slot)
				}
			}
		}
	}
	log.Info("rebalance finish")
	return nil
}
開發者ID:superwood,項目名稱:reborn,代碼行數:51,代碼來源:rebalancer.go

示例11: TestPrewriteSecondaryMissingRows

// Fix https://github.com/pingcap/go-themis/issues/19
func (s *TransactionTestSuit) TestPrewriteSecondaryMissingRows(c *C) {
	conf := defaultTxnConf
	hook := createChoosePrimaryRowHook("A")
	hook.beforePrewriteSecondary = func(txn *themisTxn, ctx interface{}) (bool, interface{}, error) {
		go func() {
			hook2 := createChoosePrimaryRowHook("B")
			hook2.onSecondaryOccursLock = func(txn *themisTxn, ctx interface{}) (bool, interface{}, error) {
				log.Info("tx2 occurs secondary lock", ctx)
				return true, nil, nil
			}
			tx2 := newTxn(s.cli, conf)
			tx2.(*themisTxn).setHook(hook2)
			tx2.Put(themisTestTableName, hbase.NewPut([]byte("A")).AddValue(cf, q, []byte("A")))
			tx2.Put(themisTestTableName, hbase.NewPut([]byte("B")).AddValue(cf, q, []byte("B")))
			tx2.Put(themisTestTableName, hbase.NewPut([]byte("C")).AddValue(cf, q, []byte("C")))
			tx2.Commit()
		}()
		time.Sleep(500 * time.Millisecond)
		return true, nil, nil
	}

	hook.onSecondaryOccursLock = func(txn *themisTxn, ctx interface{}) (bool, interface{}, error) {
		log.Info("tx1", ctx)
		return true, nil, nil
	}

	hook.onPrewriteRow = func(txn *themisTxn, ctx interface{}) (bool, interface{}, error) {
		containPrimary := ctx.([]interface{})[1].(bool)
		if !containPrimary {
			rm := ctx.([]interface{})[0].(*rowMutation)
			log.Info(string(rm.row))
		}

		return true, nil, nil
	}

	tx1 := newTxn(s.cli, conf)
	tx1.(*themisTxn).setHook(hook)
	tx1.Put(themisTestTableName, hbase.NewPut([]byte("A")).AddValue(cf, q, []byte("A")))
	tx1.Put(themisTestTableName, hbase.NewPut([]byte("B")).AddValue(cf, q, []byte("B")))
	tx1.Put(themisTestTableName, hbase.NewPut([]byte("C")).AddValue(cf, q, []byte("C")))
	err := tx1.Commit()
	c.Assert(err, IsNil)

	tx3 := newTxn(s.cli, conf)
	rs, err := tx3.Get(themisTestTableName, hbase.NewGet([]byte("C")).AddColumn(cf, q))
	c.Assert(rs, NotNil)
	c.Assert(err, IsNil)
	tx3.Commit()
}
開發者ID:pingcap,項目名稱:go-themis,代碼行數:51,代碼來源:txn_test.go

示例12: TestAddSlaveToEmptyGroup

func (s *testModelSuite) TestAddSlaveToEmptyGroup(c *C) {
	log.Info("[TestAddSlaveToEmptyGroup][start]")
	fakeCoordConn := zkhelper.NewConn()

	g := NewServerGroup(productName, 1)
	g.Create(fakeCoordConn)

	s1 := NewServer(SERVER_TYPE_SLAVE, s.s1.addr)
	err := g.AddServer(fakeCoordConn, s1, auth)
	c.Assert(err, IsNil)
	c.Assert(g.Servers[0].Type, Equals, SERVER_TYPE_MASTER)

	fakeCoordConn.Close()
	log.Info("[TestAddSlaveToEmptyGroup][end]")
}
開發者ID:XMAN-WOMBAT,項目名稱:reborn,代碼行數:15,代碼來源:server_group_test.go

示例13: TestServerGroup

func (s *testModelSuite) TestServerGroup(c *C) {
	log.Info("[TestServerGroup][start]")
	fakeCoordConn := zkhelper.NewConn()

	g := NewServerGroup(productName, 1)
	g.Create(fakeCoordConn)

	// test create new group
	groups, err := ServerGroups(fakeCoordConn, productName)
	c.Assert(err, IsNil)
	c.Assert(len(groups), Not(Equals), 0)

	ok, err := g.Exists(fakeCoordConn)
	c.Assert(err, IsNil)
	c.Assert(ok, Equals, true)

	gg, err := GetGroup(fakeCoordConn, productName, 1)
	c.Assert(err, IsNil)
	c.Assert(gg, NotNil)
	c.Assert(gg.Id, Equals, g.Id)

	s1 := NewServer(SERVER_TYPE_MASTER, s.s1.addr)
	s2 := NewServer(SERVER_TYPE_MASTER, s.s2.addr)

	err = g.AddServer(fakeCoordConn, s1, auth)
	c.Assert(err, IsNil)

	servers, err := g.GetServers(fakeCoordConn)
	c.Assert(err, IsNil)
	c.Assert(len(servers), Equals, 1)

	g.AddServer(fakeCoordConn, s2, auth)
	c.Assert(len(g.Servers), Equals, 1)

	s2.Type = SERVER_TYPE_SLAVE
	g.AddServer(fakeCoordConn, s2, auth)
	c.Assert(len(g.Servers), Equals, 2)

	err = g.Promote(fakeCoordConn, s2.Addr, auth)
	c.Assert(err, IsNil)

	m, err := g.Master(fakeCoordConn)
	c.Assert(err, IsNil)
	c.Assert(m.Addr, Equals, s2.Addr)

	fakeCoordConn.Close()
	log.Info("[TestServerGroup][stop]")
}
開發者ID:XMAN-WOMBAT,項目名稱:reborn,代碼行數:48,代碼來源:server_group_test.go

示例14: TestParallelHbaseCall

func (s *ParallelTestSuit) TestParallelHbaseCall(c *C) {
	runtime.GOMAXPROCS(runtime.NumCPU() / 2)
	cli, err := createHBaseClient()
	c.Assert(err, Equals, nil)

	err = createNewTableAndDropOldTable(cli, themisTestTableName, "cf", nil)
	c.Assert(err, Equals, nil)

	wg := sync.WaitGroup{}
	for i := 0; i < 10; i++ {
		wg.Add(1)
		go func(i int) {
			defer wg.Done()
			tx := newTxn(cli, defaultTxnConf)
			p := hbase.NewPut(getTestRowKey(c))
			p.AddValue(cf, q, []byte(strconv.Itoa(i)))
			tx.Put(themisTestTableName, p)
			tx.Commit()
		}(i)
	}
	wg.Wait()

	g := hbase.NewGet(getTestRowKey(c)).AddColumn(cf, q)
	rs, err := cli.Get(themisTestTableName, g)
	if err != nil {
		log.Fatal(err)
	}
	log.Info(string(rs.SortedColumns[0].Value))
}
開發者ID:yzl11,項目名稱:vessel,代碼行數:29,代碼來源:parallel_test.go

示例15: responseAction

func (s *Server) responseAction(seq int64) {
	log.Info("send response", seq)
	err := s.top.DoResponse(int(seq), &s.pi)
	if err != nil {
		log.Error(errors.ErrorStack(err))
	}
}
開發者ID:GavinHwa,項目名稱:reborn,代碼行數:7,代碼來源:router.go


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