本文整理匯總了Golang中github.com/funkygao/log4go.Debug函數的典型用法代碼示例。如果您正苦於以下問題:Golang Debug函數的具體用法?Golang Debug怎麽用?Golang Debug使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Debug函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: warmUp
func (this *FunServantImpl) warmUp() {
log.Debug("warming up...")
if this.mg != nil {
go this.mg.Warmup()
}
if this.mc != nil {
go this.mc.Warmup()
}
if this.my != nil {
this.my.Warmup()
}
if this.proxy != nil {
this.proxy.Warmup()
}
if this.rd != nil {
this.rd.Warmup()
}
log.Debug("warmup done")
}
示例2: wsReadPump
func (this *subServer) wsReadPump(clientGone chan struct{}, ws *websocket.Conn) {
ws.SetReadLimit(this.wsReadLimit)
ws.SetReadDeadline(time.Now().Add(this.wsPongWait))
ws.SetPongHandler(func(string) error {
ws.SetReadDeadline(time.Now().Add(this.wsPongWait))
return nil
})
// if kateway shutdown while there are open ws conns, the shutdown will
// wait 1m: this.subServer.wsPongWait
for {
_, message, err := ws.ReadMessage()
if err != nil {
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
log.Warn("%s: %v", ws.RemoteAddr(), err)
} else {
log.Debug("%s: %v", ws.RemoteAddr(), err)
}
close(clientGone)
break
}
log.Debug("ws[%s] read: %s", ws.RemoteAddr(), string(message))
}
}
示例3: MgInsert
func (this *FunServantImpl) MgInsert(ctx *rpc.Context,
kind string, table string, shardId int32,
doc []byte, options []byte) (r bool, intError error) {
log.Debug("%s %d %s %s %v %s", kind, shardId, table,
string(doc), doc, string(options))
var sess *mongo.Session
sess, intError = this.mongoSession(kind, shardId)
if intError != nil {
return
}
var bdoc = bson.M{}
json.Unmarshal(doc, &bdoc)
log.Debug("%+v", bdoc)
err := sess.DB().C(table).Insert(bdoc)
if err == nil {
r = true
} else {
log.Error(err)
}
sess.Recyle(&err)
return
}
示例4: LaunchHttpServer
func LaunchHttpServer(listenAddr string, debugAddr string) (err error) {
if httpApi != nil {
return httpDupLaunch
}
httpApi = new(httpRestApi)
httpApi.httpPaths = make([]string, 0, 10)
httpApi.httpRouter = mux.NewRouter()
httpApi.httpServer = &http.Server{
Addr: listenAddr,
Handler: httpApi.httpRouter,
}
httpApi.httpListener, err = net.Listen("tcp", httpApi.httpServer.Addr)
if err != nil {
httpApi = nil
return err
}
if debugAddr != "" {
log.Debug("HTTP serving at %s with pprof at %s", listenAddr, debugAddr)
} else {
log.Debug("HTTP serving at %s", listenAddr)
}
go httpApi.httpServer.Serve(httpApi.httpListener)
if debugAddr != "" {
go http.ListenAndServe(debugAddr, nil)
}
return nil
}
示例5: handleDueJobs
// TODO batch DELETE/INSERT for better performance.
func (this *JobExecutor) handleDueJobs(wg *sync.WaitGroup) {
defer wg.Done()
var (
// zabbix maintains a in-memory delete queue
// delete from history_uint where itemid=? and clock<min_clock
sqlDeleteJob = fmt.Sprintf("DELETE FROM %s WHERE job_id=?", this.table)
sqlInsertArchive = fmt.Sprintf("INSERT INTO %s(job_id,payload,ctime,due_time,etime,actor_id) VALUES(?,?,?,?,?,?)",
jm.HistoryTable(this.topic))
sqlReinject = fmt.Sprintf("INSERT INTO %s(job_id, payload, ctime, due_time) VALUES(?,?,?,?)", this.table)
)
for {
select {
case <-this.stopper:
return
case item := <-this.dueJobs:
now := time.Now()
affectedRows, _, err := this.mc.Exec(jm.AppPool, this.table, this.aid, sqlDeleteJob, item.JobId)
if err != nil {
log.Error("%s: %s", this.ident, err)
continue
}
if affectedRows == 0 {
// 2 possibilities:
// - client Cancel job wins
// - this handler is too slow and the job fetched twice in tick
continue
}
log.Debug("%s land %s", this.ident, item)
_, _, err = store.DefaultPubStore.SyncPub(this.cluster, this.topic, nil, item.Payload)
if err != nil {
err = hh.Default.Append(this.cluster, this.topic, nil, item.Payload)
}
if err != nil {
// pub fails and hinted handoff also fails: reinject job back to mysql
log.Error("%s: %s", this.ident, err)
this.mc.Exec(jm.AppPool, this.table, this.aid, sqlReinject,
item.JobId, item.Payload, item.Ctime, item.DueTime)
continue
}
log.Debug("%s fired %s", this.ident, item)
this.auditor.Trace(item.String())
// mv job to archive table
_, _, err = this.mc.Exec(jm.AppPool, this.table, this.aid, sqlInsertArchive,
item.JobId, item.Payload, item.Ctime, item.DueTime, now.Unix(), this.parentId)
if err != nil {
log.Error("%s: %s", this.ident, err)
} else {
log.Debug("%s archived %s", this.ident, item)
}
}
}
}
示例6: LoadConfig
func (this *ConfigProxy) LoadConfig(selfAddr string, cf *conf.Conf) {
if selfAddr == "" {
panic("proxy self addr unknown")
}
this.PoolCapacity = cf.Int("pool_capacity", 10)
this.IdleTimeout = cf.Duration("idle_timeout", 0)
this.IoTimeout = cf.Duration("io_timeout", time.Second*10)
this.BorrowTimeout = cf.Duration("borrow_timeout", time.Second*10)
this.DiagnosticInterval = cf.Duration("diagnostic_interval", time.Second*5)
this.TcpNoDelay = cf.Bool("tcp_nodelay", true)
this.BufferSize = cf.Int("buffer_size", 4<<10)
this.SelfAddr = selfAddr
parts := strings.SplitN(this.SelfAddr, ":", 2)
if parts[0] == "" {
// auto get local ip when self_addr like ":9001"
ips, _ := ip.LocalIpv4Addrs()
if len(ips) == 0 {
panic("cannot get local ip address")
}
this.SelfAddr = ips[0] + ":" + parts[1]
}
log.Debug("proxy conf: %+v", *this)
}
示例7: LoadConfig
func (this *ConfigMongodb) LoadConfig(cf *conf.Conf) {
this.ShardBaseNum = cf.Int("shard_base_num", 100000)
this.DebugProtocol = cf.Bool("debug_protocol", false)
this.DebugHeartbeat = cf.Bool("debug_heartbeat", false)
this.ShardStrategy = cf.String("shard_strategy", "legacy")
this.ConnectTimeout = cf.Duration("connect_timeout", 4*time.Second)
this.IoTimeout = cf.Duration("io_timeout", 30*time.Second)
this.MaxIdleConnsPerServer = cf.Int("max_idle_conns_per_server", 2)
this.MaxConnsPerServer = cf.Int("max_conns_per_server",
this.MaxIdleConnsPerServer*5)
this.HeartbeatInterval = cf.Int("heartbeat_interval", 120)
section, err := cf.Section("breaker")
if err == nil {
this.Breaker.loadConfig(section)
}
this.Servers = make(map[string]*ConfigMongodbServer)
for i := 0; i < len(cf.List("servers", nil)); i++ {
section, err := cf.Section(fmt.Sprintf("servers[%d]", i))
if err != nil {
panic(err)
}
server := new(ConfigMongodbServer)
server.ShardBaseNum = this.ShardBaseNum
server.loadConfig(section)
this.Servers[server.Pool] = server
}
log.Debug("mongodb conf: %+v", *this)
}
示例8: processConsumerOffsetsMessage
// consume topic: __consumer_offsets and process the message to get offsets of consumers
func (this *ZkCluster) processConsumerOffsetsMessage(msg *sarama.ConsumerMessage) {
var keyver, valver uint16
var partition uint32
var offset, timestamp uint64
buf := bytes.NewBuffer(msg.Key)
err := binary.Read(buf, binary.BigEndian, &keyver)
if (err != nil) || ((keyver != 0) && (keyver != 1)) {
log.Warn("Failed to decode %s:%v offset %v: keyver", msg.Topic, msg.Partition, msg.Offset)
return
}
group, err := readString(buf)
if err != nil {
log.Warn("Failed to decode %s:%v offset %v: group", msg.Topic, msg.Partition, msg.Offset)
return
}
topic, err := readString(buf)
if err != nil {
log.Warn("Failed to decode %s:%v offset %v: topic", msg.Topic, msg.Partition, msg.Offset)
return
}
err = binary.Read(buf, binary.BigEndian, &partition)
if err != nil {
log.Warn("Failed to decode %s:%v offset %v: partition", msg.Topic, msg.Partition, msg.Offset)
return
}
buf = bytes.NewBuffer(msg.Value)
err = binary.Read(buf, binary.BigEndian, &valver)
if (err != nil) || ((valver != 0) && (valver != 1)) {
log.Warn("Failed to decode %s:%v offset %v: valver", msg.Topic, msg.Partition, msg.Offset)
return
}
err = binary.Read(buf, binary.BigEndian, &offset)
if err != nil {
log.Warn("Failed to decode %s:%v offset %v: offset", msg.Topic, msg.Partition, msg.Offset)
return
}
_, err = readString(buf)
if err != nil {
log.Warn("Failed to decode %s:%v offset %v: metadata", msg.Topic, msg.Partition, msg.Offset)
return
}
err = binary.Read(buf, binary.BigEndian, ×tamp)
if err != nil {
log.Warn("Failed to decode %s:%v offset %v: timestamp", msg.Topic, msg.Partition, msg.Offset)
return
}
partitionOffset := &PartitionOffset{
Cluster: this.Name(),
Topic: topic,
Partition: int32(partition),
Group: group,
Timestamp: int64(timestamp),
Offset: int64(offset),
}
log.Debug("%+v", partitionOffset)
return
}
示例9: commitOffsets
func (this *subServer) commitOffsets() {
for cluster, clusterTopic := range this.ackedOffsets {
zkcluster := meta.Default.ZkCluster(cluster)
for topic, groupPartition := range clusterTopic {
for group, partitionOffset := range groupPartition {
for partition, offset := range partitionOffset {
if offset == -1 {
// this slot is empty
continue
}
log.Debug("cluster[%s] group[%s] commit offset {T:%s/%d O:%d}", cluster, group, topic, partition, offset)
if err := zkcluster.ResetConsumerGroupOffset(topic, group, strconv.Itoa(partition), offset); err != nil {
log.Error("cluster[%s] group[%s] commit offset {T:%s/%d O:%d} %v", cluster, group, topic, partition, offset, err)
if err == zk.ErrNoNode {
// invalid offset commit request, will not retry
this.ackedOffsets[cluster][topic][group][partition] = -1
}
} else {
// mark this slot empty
this.ackedOffsets[cluster][topic][group][partition] = -1
}
}
}
}
}
}
示例10: newMysql
func newMysql(dsn string, maxStmtCached int, bc *config.ConfigBreaker) *mysql {
this := new(mysql)
if bc == nil {
bc = &config.ConfigBreaker{
FailureAllowance: 5,
RetryTimeout: time.Second * 10,
}
}
this.dsn = dsn
this.breaker = &breaker.Consecutive{
FailureAllowance: bc.FailureAllowance,
RetryTimeout: bc.RetryTimeout}
if maxStmtCached > 0 {
this.stmtsStore = cache.NewLruCache(maxStmtCached)
this.stmtsStore.OnEvicted = func(key cache.Key, value interface{}) {
query := key.(string)
stmt := value.(*sql.Stmt)
stmt.Close()
log.Debug("[%s] stmt[%s] closed", this.dsn, query)
}
}
return this
}
示例11: diagnose
func (this *Ping) diagnose() {
this.zkzone.ForSortedClusters(func(zkcluster *zk.ZkCluster) {
registeredBrokers := zkcluster.RegisteredInfo().Roster
for _, broker := range registeredBrokers {
log.Debug("ping %s", broker.Addr())
kfk, err := sarama.NewClient([]string{broker.Addr()}, sarama.NewConfig())
if err != nil {
log.Error("%25s %30s %s", broker.Addr(), broker.NamedAddr(), color.Red(err.Error()))
continue
}
_, err = kfk.Topics() // kafka didn't provide ping, so use Topics() as ping
if err != nil {
log.Error("%25s %30s %s", broker.Addr(), broker.NamedAddr(), color.Red(err.Error()))
} else {
if !this.problematicMode {
log.Info("%25s %30s %s", broker.Addr(), broker.NamedAddr(), color.Green("ok"))
}
}
kfk.Close()
}
})
}
示例12: LoadConfig
func (this *ConfigMemcache) LoadConfig(cf *conf.Conf) {
this.Servers = make(map[string]*ConfigMemcacheServer)
this.HashStrategy = cf.String("hash_strategy", "standard")
this.Timeout = cf.Duration("timeout", 4*time.Second)
this.ReplicaN = cf.Int("replica_num", 1)
section, err := cf.Section("breaker")
if err == nil {
this.Breaker.loadConfig(section)
}
this.MaxIdleConnsPerServer = cf.Int("max_idle_conns_per_server", 3)
this.MaxConnsPerServer = cf.Int("max_conns_per_server",
this.MaxIdleConnsPerServer*10)
for i := 0; i < len(cf.List("servers", nil)); i++ {
section, err := cf.Section(fmt.Sprintf("servers[%d]", i))
if err != nil {
panic(err)
}
server := new(ConfigMemcacheServer)
server.loadConfig(section)
this.Servers[server.Address()] = server
}
log.Debug("memcache conf: %+v", *this)
}
示例13: discoverPeers
func (this *Peer) discoverPeers() {
defer func() {
this.c.Close() // leave the multicast group
}()
var msg peerMessage
reader := bufio.NewReader(this.c)
for {
// net.ListenMulticastUDP sets IP_MULTICAST_LOOP=0 as
// default, so you never receive your own sent data
// if you run both sender and receiver on (logically) same IP host
line, _, err := reader.ReadLine()
if err != nil {
log.Error(err)
continue
}
if err := msg.unmarshal(line); err != nil {
// Not our protocol, it may be SSDP or else
continue
}
log.Debug("received peer: %+v", msg)
neighborIp, present := msg["ip"]
if !present {
log.Info("Peer msg has no 'ip'")
continue
}
this.refreshNeighbor(neighborIp.(string))
}
}
示例14: Close
// Close must be called before Recycle
func (this *syncProducerClient) Close() {
log.Debug("cluster[%s] closing kafka sync client: %d", this.cluster, this.id)
// will close the producer and the kafka tcp conn
this.SyncProducer.Close()
this.closed = true
}
示例15: LoadConfig
func (this *ConfigRedis) LoadConfig(cf *conf.Conf) {
section, err := cf.Section("breaker")
if err == nil {
this.Breaker.loadConfig(section)
}
this.Servers = make(map[string]map[string]*ConfigRedisServer)
for i := 0; i < len(cf.List("pools", nil)); i++ {
section, err := cf.Section(fmt.Sprintf("pools[%d]", i))
if err != nil {
panic(err)
}
pool := section.String("name", "")
if pool == "" {
panic("Empty redis pool name")
}
this.Servers[pool] = make(map[string]*ConfigRedisServer)
// get servers in each pool
for j := 0; j < len(section.List("servers", nil)); j++ {
server, err := section.Section(fmt.Sprintf("servers[%d]", j))
if err != nil {
panic(err)
}
redisServer := new(ConfigRedisServer)
redisServer.loadConfig(server)
this.Servers[pool][redisServer.Addr] = redisServer
}
}
log.Debug("redis conf: %+v", *this)
}