本文整理匯總了Golang中github.com/ngaut/log.Debug函數的典型用法代碼示例。如果您正苦於以下問題:Golang Debug函數的具體用法?Golang Debug怎麽用?Golang Debug使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Debug函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleSet
func (c *Session) handleSet(stmt *parser.Set, sql string) error {
if len(stmt.VarList) < 1 {
return fmt.Errorf("must set one item at least")
}
var err error
for _, v := range stmt.VarList {
if strings.ToUpper(v.Name) == "AUTOCOMMIT" {
log.Debug("handle autocommit")
err = c.handleSetAutoCommit(v.Value) //??
}
}
if err != nil {
return err
}
defer func() {
//only execute when the autocommit 0->1 //clear
if c.autoCommit == 1 {
log.Debug("clear autocommit tx")
c.clearAutoCommitTx()
}
}()
return c.handleOtherSet(stmt, sql)
}
示例2: Serve
func (s *Server) Serve() error {
log.Debug("this is ddbatman v4")
s.running = true
var sessionId int64 = 0
for s.running {
select {
case sessionChan <- sessionId:
//do nothing
default:
//warnning!
log.Warnf("TASK_CHANNEL is full!")
}
conn, err := s.Accept()
if err != nil {
log.Warning("accept error %s", err.Error())
continue
}
//allocate a sessionId for a session
go s.onConn(conn)
sessionId += 1
}
if s.restart == true {
log.Debug("Begin to restart graceful")
listenerFile, err := s.listener.(*net.TCPListener).File()
if err != nil {
log.Fatal("Fail to get socket file descriptor:", err)
}
listenerFd := listenerFile.Fd()
os.Setenv("_GRACEFUL_RESTART", "true")
execSpec := &syscall.ProcAttr{
Env: os.Environ(),
Files: []uintptr{os.Stdin.Fd(), os.Stdout.Fd(), os.Stderr.Fd(), listenerFd},
}
fork, err := syscall.ForkExec(os.Args[0], os.Args, execSpec)
if err != nil {
return fmt.Errorf("failed to forkexec: %v", err)
}
log.Infof("start new process success, pid %d.", fork)
}
timeout := time.NewTimer(time.Minute)
wait := make(chan struct{})
go func() {
s.wg.Wait()
wait <- struct{}{}
}()
select {
case <-timeout.C:
log.Error("server : Waittimeout error when close the service")
return nil
case <-wait:
log.Info("server : all goroutine has been done")
return nil
}
return nil
}
示例3: logger
func logger(runmode string) macaron.Handler {
return func(ctx *macaron.Context) {
if runmode == "dev" {
log.Debug("")
log.Debug("----------------------------------------------------------------------------------")
}
log.Infof("[%s] [%s]", ctx.Req.Method, ctx.Req.RequestURI)
log.Infof("[Header] %v", ctx.Req.Header)
}
}
示例4: checkExpiredKeysWorker
func (gc *localstoreCompactor) checkExpiredKeysWorker() {
defer gc.workerWaitGroup.Done()
for {
select {
case <-gc.stopCh:
log.Debug("[kv] 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()
for k := range m {
err := gc.Compact([]byte(k))
if err != nil {
log.Error(err)
}
}
}
}
}
示例5: TestTable
func (s *testStatisticsSuite) TestTable(c *C) {
tblInfo := &model.TableInfo{
ID: 1,
}
columns := []*model.ColumnInfo{
{
ID: 2,
FieldType: *types.NewFieldType(mysql.TypeLonglong),
},
}
tblInfo.Columns = columns
timestamp := int64(10)
bucketCount := int64(256)
t, err := NewTable(tblInfo, timestamp, s.count, bucketCount, [][]types.Datum{s.samples})
c.Check(err, IsNil)
str := t.String()
log.Debug(str)
c.Check(len(str), Greater, 0)
tpb, err := t.ToPB()
c.Check(err, IsNil)
data, err := proto.Marshal(tpb)
c.Check(err, IsNil)
ntpb := &TablePB{}
err = proto.Unmarshal(data, ntpb)
c.Check(err, IsNil)
nt, err := TableFromPB(tblInfo, ntpb)
c.Check(err, IsNil)
c.Check(nt.String(), Equals, str)
}
示例6: cmdDashboard
func cmdDashboard(argv []string) (err error) {
usage := `usage: reborn-config dashboard [--addr=<address>] [--http-log=<log_file>]
options:
--addr listen ip:port, e.g. localhost:12345, :8086, [default: :8086]
--http-log http request log [default: request.log ]
`
args, err := docopt.Parse(usage, argv, true, "", false)
if err != nil {
log.Error(err)
return errors.Trace(err)
}
log.Debug(args)
logFileName := "request.log"
if args["--http-log"] != nil {
logFileName = args["--http-log"].(string)
}
addr := ":8086"
if args["--addr"] != nil {
addr = args["--addr"].(string)
}
runDashboard(addr, logFileName)
return nil
}
示例7: DelKeyWithPrefix
// DelKeyWithPrefix deletes keys with prefix.
func DelKeyWithPrefix(ctx context.Context, prefix string) error {
log.Debug("delKeyWithPrefix", prefix)
txn, err := ctx.GetTxn(false)
if err != nil {
return err
}
var keys []string
iter, err := txn.Seek([]byte(prefix), hasPrefix([]byte(prefix)))
if err != nil {
return err
}
defer iter.Close()
for {
if err != nil {
return err
}
if iter.Valid() && strings.HasPrefix(iter.Key(), prefix) {
keys = append(keys, iter.Key())
iter, err = iter.Next(hasPrefix([]byte(prefix)))
} else {
break
}
}
for _, key := range keys {
err := txn.Delete([]byte(key))
if err != nil {
return err
}
}
return nil
}
示例8: init
// init and get root region server addr and master addr
func (c *client) init() error {
zkclient, _, err := zk.Connect(c.zkHosts, time.Second*30)
if err != nil {
return err
}
c.zkClient = zkclient
res, _, _, err := c.zkClient.GetW(c.zkRoot + zkRootRegionPath)
if err != nil {
return err
}
c.rootServerName, err = c.decodeMeta(res)
if err != nil {
return err
}
log.Debug("connect root region server...", c.rootServerName)
conn, err := newConnection(serverNameToAddr(c.rootServerName), false)
if err != nil {
return err
}
// set buffered regionserver conn
c.cachedConns[serverNameToAddr(c.rootServerName)] = conn
res, _, _, err = c.zkClient.GetW(c.zkRoot + zkMasterAddrPath)
if err != nil {
return err
}
c.masterServerName, err = c.decodeMeta(res)
if err != nil {
return err
}
return nil
}
示例9: 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
}
示例10: exec
func exec(sqlStmt string) error {
db := connPool.Get().(*sql.DB)
defer connPool.Put(db)
log.Debug("exec sql:", sqlStmt)
_, err := db.Exec(sqlStmt)
return err
}
示例11: statement
func statement(ctx context.Context, sql string) stmt.Statement {
log.Debug("[ddl] Compile", sql)
s, _ := parser.ParseOneStmt(sql, "", "")
compiler := &executor.Compiler{}
stm, _ := compiler.Compile(ctx, s)
return stm
}
示例12: 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
}
示例13: cmdProxy
func cmdProxy(argv []string) (err error) {
usage := `usage:
reborn-config proxy list
reborn-config proxy offline <proxy_name>
reborn-config proxy online <proxy_name>
`
args, err := docopt.Parse(usage, argv, true, "", false)
if err != nil {
log.Error(err)
return err
}
log.Debug(args)
if args["list"].(bool) {
return runProxyList()
}
proxyName := args["<proxy_name>"].(string)
if args["online"].(bool) {
return runSetProxyStatus(proxyName, models.PROXY_STATE_ONLINE)
}
if args["offline"].(bool) {
return runSetProxyStatus(proxyName, models.PROXY_STATE_MARK_OFFLINE)
}
return nil
}
示例14: backfillIndexInTxn
// backfillIndexInTxn deals with a part of backfilling index data in a Transaction.
// This part of the index data rows is defaultSmallBatchCnt.
func (d *ddl) backfillIndexInTxn(t table.Table, kvIdx table.Index, handles []int64, txn kv.Transaction) (int64, error) {
idxRecords, err := d.fetchRowColVals(txn, t, handles, kvIdx.Meta())
if err != nil {
return 0, errors.Trace(err)
}
for _, idxRecord := range idxRecords {
log.Debug("[ddl] backfill index...", idxRecord.handle)
err = txn.LockKeys(idxRecord.key)
if err != nil {
return 0, errors.Trace(err)
}
// Create the index.
handle, err := kvIdx.Create(txn, idxRecord.vals, idxRecord.handle)
if err != nil {
if terror.ErrorEqual(err, kv.ErrKeyExists) && idxRecord.handle == handle {
// Index already exists, skip it.
continue
}
return 0, errors.Trace(err)
}
}
return idxRecords[len(idxRecords)-1].handle, nil
}
示例15: isValid
func (b Block) isValid() bool {
if b.nodeID < MinNodeId {
logger.Debug("Block invalid")
return true
}
return true
}