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


Golang log4go.Debug函数代码示例

本文整理汇总了Golang中code/google/com/p/log4go.Debug函数的典型用法代码示例。如果您正苦于以下问题:Golang Debug函数的具体用法?Golang Debug怎么用?Golang Debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: auth

// auth for goim handshake with client, use rsa & aes.
func (server *Server) auth(rr io.Reader, wr io.Writer, fr Flusher, dbm cipher.BlockMode, p *Proto) (subKey string, heartbeat time.Duration, err error) {
	log.Debug("get auth request protocol")
	if err = server.readRequest(rr, p); err != nil {
		return
	}
	if p.Operation != OP_AUTH {
		log.Warn("auth operation not valid: %d", p.Operation)
		err = ErrOperation
		return
	}
	if p.Body, err = server.cryptor.Decrypt(dbm, p.Body); err != nil {
		log.Error("auth decrypt client proto error(%v)", err)
		return
	}
	if subKey, heartbeat, err = server.operator.Connect(p); err != nil {
		log.Error("operator.Connect error(%v)", err)
		return
	}
	log.Debug("send auth response protocol")
	p.Body = nil
	p.Operation = OP_AUTH_REPLY
	if err = server.sendResponse(wr, fr, p); err != nil {
		log.Error("[%s] server.SendResponse() error(%v)", subKey, err)
	}
	return
}
开发者ID:zhoudianyou,项目名称:goim,代码行数:27,代码来源:server.go

示例2: GameStateFinishing

/*
 *	GameStateFinishing
 *	All bets are over. Now collect the words made by users and compute the winner and give him the pot amount.
 *	BREAKS ON: computing winner finished
 */
func (g *Game) GameStateFinishing() {
	defer func() {
		recover()
	}()
	for {
		select {
		case <-g.stateFinishing:
			log.Debug("STATE: finishing")
			winnerIds := make([]string, 0)
			winners := g.computeWinner()
			if len(winners) > 0 {
				winnerShare := g.PotAmount / len(winners)
				for _, p := range winners {
					if p != nil {
						p.Cash += winnerShare
						winnerIds = append(winnerIds, strconv.Itoa(p.Id))
					}
				}
				log.Debug("Winners: %v", winnerIds)
			} else {
				log.Debug("No winner. House wins the pot.")
			}
			g.sendUpdate(ACT_GAME_OVER, strings.Join(winnerIds, ","), 0, nil)

			time.Sleep(time.Millisecond * DUR_WAIT_GAME_OVER)

			log.Debug("---- end of game ----")

			g.State = GS_WAITING
			g.stateWaiting <- 1
		}
	}
}
开发者ID:chun337163833,项目名称:word-poker,代码行数:38,代码来源:gameStates.go

示例3: createDbUser

func (self *HttpServer) createDbUser(w libhttp.ResponseWriter, r *libhttp.Request) {
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		w.WriteHeader(libhttp.StatusInternalServerError)
		w.Write([]byte(err.Error()))
		return
	}

	newUser := &NewUser{}
	err = json.Unmarshal(body, newUser)
	if err != nil {
		w.WriteHeader(libhttp.StatusBadRequest)
		w.Write([]byte(err.Error()))
		return
	}

	db := r.URL.Query().Get(":db")

	self.tryAsDbUserAndClusterAdmin(w, r, func(u User) (int, interface{}) {
		username := newUser.Name
		if err := self.userManager.CreateDbUser(u, db, username, newUser.Password); err != nil {
			log.Error("Cannot create user: %s", err)
			return errorToStatusCode(err), err.Error()
		}
		log.Debug("Created user %s", username)
		if newUser.IsAdmin {
			err = self.userManager.SetDbAdmin(u, db, newUser.Name, true)
			if err != nil {
				return libhttp.StatusInternalServerError, err.Error()
			}
		}
		log.Debug("Successfully changed %s password", username)
		return libhttp.StatusOK, nil
	})
}
开发者ID:kennylixi,项目名称:influxdb,代码行数:35,代码来源:api.go

示例4: processAppendEntry

func (self *WAL) processAppendEntry(e *appendEntry) {
	nextRequestNumber := self.state.getNextRequestNumber()
	e.request.RequestNumber = proto.Uint32(nextRequestNumber)

	if len(self.logFiles) == 0 {
		if _, err := self.createNewLog(nextRequestNumber); err != nil {
			e.confirmation <- &confirmation{0, err}
			return
		}
		self.state.FirstSuffix = nextRequestNumber
	}

	lastLogFile := self.logFiles[len(self.logFiles)-1]
	self.assignSequenceNumbers(e.shardId, e.request)
	logger.Debug("appending request %d", e.request.GetRequestNumber())
	err := lastLogFile.appendRequest(e.request, e.shardId)
	if err != nil {
		e.confirmation <- &confirmation{0, err}
		return
	}
	self.state.CurrentFileOffset = self.logFiles[len(self.logFiles)-1].offset()

	self.requestsSinceLastIndex++
	self.requestsSinceLastBookmark++
	self.requestsSinceLastFlush++
	self.requestsSinceRotation++
	logger.Debug("requestsSinceRotation: %d", self.requestsSinceRotation)
	if rotated, err := self.rotateTheLogFile(nextRequestNumber); err != nil || rotated {
		e.confirmation <- &confirmation{e.request.GetRequestNumber(), err}
		return
	}

	self.conditionalBookmarkAndIndex()
	e.confirmation <- &confirmation{e.request.GetRequestNumber(), nil}
}
开发者ID:hyc,项目名称:influxdb,代码行数:35,代码来源:wal.go

示例5: Yield

func (self *Passthrough) Yield(seriesIncoming *protocol.Series) (bool, error) {
	log.Debug("PassthroughEngine YieldSeries %d", len(seriesIncoming.Points))

	self.limiter.calculateLimitAndSlicePoints(seriesIncoming)
	if len(seriesIncoming.Points) == 0 {
		return false, nil
	}

	if self.series == nil {
		self.series = seriesIncoming
	} else if self.series.GetName() != seriesIncoming.GetName() {
		log.Debug("Yielding to %s: %s", self.next.Name(), self.series)
		ok, err := self.next.Yield(self.series)
		if !ok || err != nil {
			return ok, err
		}
		self.series = seriesIncoming
	} else if len(self.series.Points) > self.maxPointsInResponse {
		log.Debug("Yielding to %s: %s", self.next.Name(), self.series)
		ok, err := self.next.Yield(self.series)
		if !ok || err != nil {
			return ok, err
		}
		self.series = seriesIncoming
	} else {
		self.series = common.MergeSeries(self.series, seriesIncoming)
	}
	return !self.limiter.hitLimit(seriesIncoming.GetName()), nil
}
开发者ID:aiyi,项目名称:influxdb,代码行数:29,代码来源:passthrough_engine.go

示例6: ReadRequestHeader

func (c *DefaultServerCodec) ReadRequestHeader(rd *bufio.Reader, proto *Proto) (err error) {
	if err = binary.Read(rd, binary.BigEndian, &proto.PackLen); err != nil {
		log.Error("packLen: binary.Read() error(%v)", err)
		return
	}
	log.Debug("packLen: %d", proto.PackLen)
	if proto.PackLen > maxPackLen {
		return ErrProtoPackLen
	}
	if err = binary.Read(rd, binary.BigEndian, &proto.HeaderLen); err != nil {
		log.Error("headerLen: binary.Read() error(%v)", err)
		return
	}
	log.Debug("headerLen: %d", proto.HeaderLen)
	if proto.HeaderLen != rawHeaderLen {
		return ErrProtoHeaderLen
	}
	if err = binary.Read(rd, binary.BigEndian, &proto.Ver); err != nil {
		log.Error("protoVer: binary.Read() error(%v)", err)
		return
	}
	log.Debug("protoVer: %d", proto.Ver)
	if err = binary.Read(rd, binary.BigEndian, &proto.Operation); err != nil {
		log.Error("Operation: binary.Read() error(%v)", err)
		return
	}
	log.Debug("operation: %d", proto.Operation)
	if err = binary.Read(rd, binary.BigEndian, &proto.SeqId); err != nil {
		log.Error("seqId: binary.Read() error(%v)", err)
		return
	}
	log.Debug("seqId: %d", proto.SeqId)
	return
}
开发者ID:xingskycn,项目名称:goim,代码行数:34,代码来源:codec.go

示例7: ReadProto

func ReadProto(rd *bufio.Reader, proto *Proto) (err error) {
	// read
	if err = binary.Read(rd, binary.BigEndian, &proto.PackLen); err != nil {
		return
	}
	log.Debug("packLen: %d", proto.PackLen)
	if err = binary.Read(rd, binary.BigEndian, &proto.HeaderLen); err != nil {
		return
	}
	log.Debug("headerLen: %d", proto.HeaderLen)
	if err = binary.Read(rd, binary.BigEndian, &proto.Ver); err != nil {
		return
	}
	log.Debug("ver: %d", proto.Ver)
	if err = binary.Read(rd, binary.BigEndian, &proto.Operation); err != nil {
		return
	}
	log.Debug("operation: %d", proto.Operation)
	if err = binary.Read(rd, binary.BigEndian, &proto.SeqId); err != nil {
		return
	}
	log.Debug("seqId: %d", proto.SeqId)
	if err = ReadBody(rd, proto); err != nil {
	}
	return
}
开发者ID:xingskycn,项目名称:goim,代码行数:26,代码来源:main.go

示例8: del

func (t *Timer) del(td *TimerData) {
	var (
		i    = td.index
		last = len(t.timers) - 1
	)
	if i < 0 || i > last || t.timers[i] != td {
		// already remove, usually by expire
		if Debug {
			log.Debug("timer del i: %d, last: %d, %p", i, last, td)
		}
		return
	}
	if i != last {
		t.swap(i, last)
		t.down(i, last)
		t.up(i)
	}
	// remove item is the last node
	t.timers[last].index = -1 // for safety
	t.timers = t.timers[:last]
	if Debug {
		log.Debug("timer: remove item key: %s, expire: %s, index: %d", td.Key, td.ExpireString(), td.index)
	}
	return
}
开发者ID:linux-mac,项目名称:goim,代码行数:25,代码来源:timer.go

示例9: Initialize

// Initializes a new Droplet application object
func (a *Application) Initialize() error {
	log.Debug("Initializing Droplet Application")

	log.Debug("Configuring Application")

	err := a.Configure()
	if err != nil {
		log.Error("Error configuring application: %s", err)
		panic(err)
	}

	log.Debug("Configuring Server Instance")

	err = a.ConfigureServer()
	if err != nil {
		log.Error("Error configuring server: ", err)
		panic(err)
	}

	log.Debug("Configuring Router")

	err = a.ConfigureRouter()
	if err != nil {
		log.Error("Error configuring router: ", err)
		panic(err)
	}

	a.Handler = func(w http.ResponseWriter, r *http.Request) {
		a.Router.ServeHTTP(w, r)
	}

	return nil
}
开发者ID:johnnadratowski,项目名称:droplet,代码行数:34,代码来源:droplet.go

示例10: RecoverServerFromRequestNumber

// In the case where this server is running and another one in the
// cluster stops responding, at some point this server will have to
// just write requests to disk. When the downed server comes back up,
// it's this server's responsibility to send out any writes that were
// queued up. If the yield function returns nil then the request is
// committed.
func (self *WAL) RecoverServerFromRequestNumber(requestNumber uint32, shardIds []uint32, yield func(request *protocol.Request, shardId uint32) error) error {
	// don't replay if we don't have any log files yet
	if len(self.logFiles) == 0 {
		return nil
	}

	firstIndex := 0
	firstOffset := int64(-1)
	// find the log file from which replay will start if the request
	// number is in range, otherwise replay from all log files
	if !self.isInRange(requestNumber) {
		return nil
	}

	for idx, logIndex := range self.logIndex {
		logger.Debug("Trying to find request %d in %s", requestNumber, self.logFiles[idx].file.Name())
		if firstOffset = logIndex.requestOffset(requestNumber); firstOffset != -1 {
			logger.Debug("Found reqeust %d in %s at offset %d", requestNumber, self.logFiles[idx].file.Name(), firstOffset)
			firstIndex = idx
			break
		}
	}

	// the request must be at the end of the current log file
	if firstOffset == -1 {
		firstIndex = len(self.logIndex) - 1
		firstOffset = self.logIndex[firstIndex].requestOrLastOffset(requestNumber)
	}
outer:
	for idx := firstIndex; idx < len(self.logFiles); idx++ {
		logFile := self.logFiles[idx]
		if idx > firstIndex {
			firstOffset = -1
		}
		logger.Info("Replaying from %s:%d", logFile.file.Name(), firstOffset)
		count := 0
		ch, stopChan := logFile.dupAndReplayFromOffset(shardIds, firstOffset, requestNumber)
		for {
			x := <-ch
			if x == nil {
				logger.Info("%s yielded %d requests", logFile.file.Name(), count)
				continue outer
			}

			if x.err != nil {
				return x.err
			}

			logger.Debug("Yielding request %d", x.request.GetRequestNumber())
			if err := yield(x.request, x.shardId); err != nil {
				logger.Debug("Stopping replay due to error: %s", err)
				stopChan <- struct{}{}
				return err
			}
			count++
		}
		close(stopChan)
	}
	return nil
}
开发者ID:richthegeek,项目名称:influxdb,代码行数:66,代码来源:wal.go

示例11: writeLoop

func (ctx *CommunicationContext) writeLoop() {
	ctx.communicating.Add(1)
	defer ctx.communicating.Done()

	log4go.Debug("write loop started")

	for ctx.isOpen {
		tckt, ok := <-ctx.Output

		if ok {
			log4go.Debug("found new output in output channel")
			err := ctx.sender.Send(tckt.msg)

			if err != nil {
				log4go.Warn("error while sending to device: %v", err.Error())
				tckt.error <- err
			} else {
				tckt.isSend = true
				tckt.send <- tckt.msg
			}
		} else {
			log4go.Warn("output channel closed")
		}
	}

	log4go.Debug("write loop finished")
}
开发者ID:pjvds,项目名称:antport,代码行数:27,代码来源:CommunicationContext.go

示例12: Query

func (self *Shard) Query(querySpec *parser.QuerySpec, processor engine.Processor) error {
	self.closeLock.RLock()
	defer self.closeLock.RUnlock()
	if self.closed {
		return fmt.Errorf("Shard is closed")
	}
	if querySpec.IsListSeriesQuery() {
		return fmt.Errorf("List series queries should never come to the shard")
	} else if querySpec.IsDeleteFromSeriesQuery() {
		return self.executeDeleteQuery(querySpec, processor)
	}

	if !self.hasReadAccess(querySpec) {
		return errors.New("User does not have access to one or more of the series requested.")
	}

	switch t := querySpec.SelectQuery().FromClause.Type; t {
	case parser.FromClauseArray:
		log.Debug("Shard %s: running a regular query", self.db.Path())
		return self.executeArrayQuery(querySpec, processor)
	case parser.FromClauseMerge, parser.FromClauseInnerJoin:
		log.Debug("Shard %s: running a merge query", self.db.Path())
		return self.executeMergeQuery(querySpec, processor, t)
	default:
		panic(fmt.Errorf("Unknown from clause type %s", t))
	}
}
开发者ID:ericcapricorn,项目名称:influxdb,代码行数:27,代码来源:shard.go

示例13: printTimer

func printTimer(timer *Timer) {
	log.Debug("----------timers: %d ----------", len(timer.timers))
	for i := 0; i < len(timer.timers); i++ {
		log.Debug("timer: %s, %s, index: %d", timer.timers[i].Key, timer.timers[i].ExpireString(), timer.timers[i].index)
	}
	log.Debug("--------------------")
}
开发者ID:Crysty-Yui,项目名称:goim,代码行数:7,代码来源:timer_test.go

示例14: auth

// auth for goim handshake with client, use rsa & aes.
func (server *Server) auth(rd *bufio.Reader, wr *bufio.Writer, dbm cipher.BlockMode, proto *Proto) (subKey string, heartbeat time.Duration, bucket *Bucket, channel *Channel, err error) {
	log.Debug("get auth request protocol")
	if err = server.readRequest(rd, proto); err != nil {
		return
	}
	if proto.Operation != OP_AUTH {
		log.Warn("auth operation not valid: %d", proto.Operation)
		err = ErrOperation
		return
	}
	if proto.Body, err = server.cryptor.Decrypt(dbm, proto.Body); err != nil {
		log.Error("auth decrypt client proto error(%v)", err)
		return
	}
	if subKey, heartbeat, err = server.operator.Connect(proto); err != nil {
		log.Error("operator.Connect error(%v)", err)
		return
	}
	// TODO how to reuse channel
	// register key->channel
	bucket = server.Bucket(subKey)
	channel = NewChannel(Conf.CliProto, Conf.SvrProto)
	bucket.Put(subKey, channel)
	log.Debug("send auth response protocol")
	proto.Body = nil
	proto.Operation = OP_AUTH_REPLY
	if err = server.sendResponse(wr, proto); err != nil {
		log.Error("[%s] server.SendResponse() error(%v)", subKey, err)
	}
	return
}
开发者ID:xingskycn,项目名称:goim,代码行数:32,代码来源:server.go

示例15: getDistrictFoodPrice

func (self *FoodPriceService) getDistrictFoodPrice(district string) (string, error) {
	foodPriceMsg, hitCache := districtFoodPriceMsgCache[district]
	if hitCache {
		l4g.Debug("Hit districtFoodPriceMsgCache, district: %s", district)
		return foodPriceMsg, nil
	}
	var districtFoodPrices []*DistrictFoodPrice
	entities, err := self.dbHelper.GetLatestDistrictFoodPriceEntity(district, int64(overTime))
	if err != nil {
		return "", err
	}
	if len(entities) > 0 {
		districtFoodPrices = self.convertDistrictEntityToFoodPrice(entities)
	}
	if len(districtFoodPrices) == 0 {
		var e error
		l4g.Debug("get %s food price from web", district)
		districtFoodPrices, e = FetchDistrictFoodPrice(district)
		if e != nil {
			return "", e
		}
	}
	if len(districtFoodPrices) == 0 {
		return "无记录", nil
	}
	msg := self.formatDistrictFoodPrice(districtFoodPrices, district)
	url, _ := GetDistrictFoodPriceUrl(district)
	msg = msg + fmt.Sprintf("\n详细信息请点击:%s", url)
	districtFoodPriceMsgCache[district] = msg
	return msg, nil
}
开发者ID:NoahShen,项目名称:MyPiAssistant,代码行数:31,代码来源:foodpriceservice.go


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