本文整理匯總了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
}
示例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
}
}
}
示例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
})
}
示例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}
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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")
}
示例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))
}
}
示例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("--------------------")
}
示例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
}
示例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
}