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


Golang logging.Debugf函數代碼示例

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


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

示例1: addReadyTask

func (self *ResMan) addReadyTask(id string) (string, error) {
	if self.ready.Exist(id) {
		return "", fmt.Errorf("%s already exist: %+v", id, self.ready.Get(id))
	}

	job, err := scheduler.GetJobById(id)
	if err != nil {
		return "", errors.Trace(err)
	}

	persistentTask := &scheduler.Task{TaskId: self.genTaskId(), Status: scheduler.STATUS_READY,
		StartTs: time.Now().Unix(), JobName: job.Name}
	log.Debugf("%+v", persistentTask)
	err = persistentTask.Save()
	if err != nil {
		return "", errors.Trace(err)
	}

	job.LastTaskId = persistentTask.TaskId
	job.Save()

	t := &Task{Tid: persistentTask.TaskId, job: job, state: taskReady}
	self.ready.Add(t.Tid, t)
	log.Debugf("ready task %+v, total count:%d", t, self.ready.Length())

	return persistentTask.TaskId, nil
}
開發者ID:NextMark,項目名稱:tyrant,代碼行數:27,代碼來源:scheduler.go

示例2: handleMesosOffers

func (self *ResMan) handleMesosOffers(t *cmdMesosOffers) {
	driver := t.driver
	offers := t.offers

	defer func() {
		t.wait <- struct{}{}
	}()

	log.Debugf("ResourceOffers %+v", offers)
	ts := self.getReadyTasks()
	log.Debugf("ready tasks:%+v", ts)
	var idx, left int

	for idx = 0; idx < len(offers); idx++ {
		n := self.runTaskUsingOffer(driver, offers[idx], ts[left:])
		if n == 0 {
			break
		}
		left += n
	}

	//decline left offers
	for i := idx; i < len(offers); i++ {
		driver.DeclineOffer(offers[i].Id)
	}
}
開發者ID:NextMark,項目名稱:tyrant,代碼行數:26,代碼來源:scheduler.go

示例3: getReadyTasks

func (self *ResMan) getReadyTasks() []*Task {
	var rts []*Task
	self.ready.Each(func(key string, t *Task) bool {
		log.Debugf("ready task:%+v", t)
		rts = append(rts, t)
		return true
	})

	log.Debugf("ready tasks: %+v", rts)

	return rts
}
開發者ID:NextMark,項目名稱:tyrant,代碼行數:12,代碼來源:scheduler.go

示例4: saveTaskStatus

func (self *ResMan) saveTaskStatus(persistentTask *scheduler.Task, status mesos.TaskStatus, currentTask *Task) {
	if persistentTask == nil {
		return
	}

	var url string
	if len(currentTask.Pwd) > 0 {
		url = fmt.Sprintf("http://%v:%v/#/slaves/%s/browse?path=%s",
			Inet_itoa(self.masterInfo.GetIp()), self.masterInfo.GetPort(), currentTask.SlaveId, currentTask.Pwd)
	} else {
		url = fmt.Sprintf("http://%v:%v/#/frameworks/%s", Inet_itoa(self.masterInfo.GetIp()),
			self.masterInfo.GetPort(), self.frameworkId)
	}
	persistentTask.Status = (*status.State).String()
	if len(status.GetMessage()) > 0 {
		persistentTask.Message = status.GetMessage()
	}
	persistentTask.Url = url
	currentTask.job.LastStatus = persistentTask.Status
	currentTask.job.Save()
	persistentTask.UpdateTs = time.Now().Unix()
	persistentTask.Save()
	switch *status.State {
	case mesos.TaskState_TASK_FINISHED, mesos.TaskState_TASK_FAILED,
		mesos.TaskState_TASK_KILLED, mesos.TaskState_TASK_LOST:
		currentTask.job.SendNotify(persistentTask)
	}

	log.Debugf("persistentTask:%+v", persistentTask)
}
開發者ID:NextMark,項目名稱:tyrant,代碼行數:30,代碼來源:scheduler.go

示例5: readHeader

func readHeader(r io.Reader) (magic uint32, tp uint32, size uint32, err error) {
	magic, err = readUint32(r)
	if err != nil {
		return
	}

	if magic != common.Req && magic != common.Res {
		log.Debugf("magic not match 0x%x", magic)
		err = invalidMagic
		return
	}

	tp, err = readUint32(r)
	if err != nil {
		return
	}

	if !validCmd(tp) {
		//gearman's bug, as protocol, we should treat this an error, but gearman allow it
		if tp == 39 { //wtf: benchmark worker send this, and i can not find it in protocol description
			tp = common.GRAB_JOB_UNIQ
			size, err = readUint32(r)
			return
		}
		err = invalidArg
		return
	}

	size, err = readUint32(r)

	return
}
開發者ID:UGuarder,項目名稱:gearmand,代碼行數:32,代碼來源:util.go

示例6: GetFileContent

// direction 0 head, 1 tail
// we only return retain-size string to Caller
func GetFileContent(filename string, retain int64, direction int) string {
	log.Debugf("GetFileContent ", filename, retain)
	f, err := os.Open(filename)
	if err != nil {
		log.Warning("GetOutPut open failed ", filename, err)
		return ""
	}
	defer f.Close()

	fs, err := f.Stat()
	if err != nil {
		log.Warning("GetOutPut get Stat failed ", filename, err)
		return ""
	}
	var buf []byte
	seek_at := int64(0)
	if fs.Size() > retain && direction == 1 {
		seek_at = fs.Size() - retain
		buf = make([]byte, retain)
	}
	buf = make([]byte, fs.Size())

	f.Seek(seek_at, 0)

	if _, err := f.Read(buf); err != nil && err != io.EOF {
		log.Warning("GetOutPut read buf failed ", err)
		return ""
	}
	return string(buf)
}
開發者ID:huangdehui2013,項目名稱:dcms,代碼行數:32,代碼來源:io.go

示例7: HitFilter

// filter must split by '|', for example "fatal|error|fail|failed"
func HitFilter(filename string, filter string) bool {
	log.Debug("HitFilter run:", filename, filter)
	filterExp, err := regexp.Compile(fmt.Sprintf(`(?i:(%s))`, filter))
	if err != nil {
		log.Warningf("HitFilter regexp.Compile for %s failed:%s", filter, err)
		return false
	}

	if f, err := os.Open(filename); err != nil {
		log.Warning("HitFilter open file failed ", filename, err)
		return false
	} else {
		defer f.Close()
		freader := bufio.NewReader(f)
		for {
			var str string
			str, err = freader.ReadString('\n')
			s := filterExp.FindStringSubmatch(str)
			if len(s) > 0 {
				log.Debugf("HitFilter hit msg_filter ", s, str)
				return true
			}
			if err == io.EOF {
				break
			}
		}
	}
	return false
}
開發者ID:huangdehui2013,項目名稱:dcms,代碼行數:30,代碼來源:io.go

示例8: SaveCronMetaData

// we will Save Cron MetaData periodically, currently for 5min
func (agent *Agent) SaveCronMetaData() {
	meta_file := fmt.Sprintf("%s/dcms_agent.metadata", agent.Conf.WorkDir)
	cronSlice := make([]string, 0)

	agent.Lock.Lock()
	defer agent.Lock.Unlock()
	for k, v := range agent.Jobs {
		if data, err := json.Marshal(v); err == nil {
			cronSlice = append(cronSlice, string(data))
		} else {
			log.Warningf("marshal task: %d failed: %s", k, err)
			return
		}
	}

	if data, err := json.Marshal(cronSlice); err != nil {
		log.Warning("json marshal cronslice failed, ", err)
	} else {
		if len(cronSlice) == 0 {
			log.Warning("cronSlice json empty, just skip write MetaData")
			return
		}
		log.Debug("len of cronSlice:", len(data), data)
		log.Debugf("cronSlice length:%d content:%s", len(cronSlice), cronSlice)
		if e := ioutil.WriteFile(meta_file, data, os.ModePerm); e != nil {
			log.Warning("ioutil write meta_file failed,", e)
		}
	}
}
開發者ID:huangdehui2013,項目名稱:dcms,代碼行數:30,代碼來源:agent.go

示例9: fetchColumns

func (ti *TableInfo) fetchColumns(conn *mysql.MySqlConn) error {
	columns, err := conn.Execute(fmt.Sprintf("show full columns from `%s`", ti.Name))
	if err != nil {
		return errors.Trace(err)
	}

	for _, row := range columns.Values {
		v, err := sqltypes.BuildValue(row[5])
		if err != nil {
			return errors.Trace(err)
		}

		var collation string
		if row[2] != nil {
			collation = string(row[2].([]byte))
		}
		extra := string(row[6].([]byte))
		columnType := string(row[1].([]byte))
		columnName := string(row[0].([]byte))
		ti.AddColumn(columnName, columnType, collation,
			v, extra)
	}

	log.Debugf("%s %+v", ti.Name, ti.Columns)

	return nil
}
開發者ID:sdgdsffdsfff,項目名稱:cm,代碼行數:27,代碼來源:table_info.go

示例10: WebhookHandler

func (s *ApiServer) WebhookHandler(w http.ResponseWriter, r *http.Request) {
	//todo: post a tyrant job and start task
	err := r.ParseForm()
	if err != nil {
		http.Error(w, errors.ErrorStack(err), http.StatusInternalServerError)
		return
	}

	vars := mux.Vars(r)
	log.Debug(vars)

	repo := r.Form.Get("repo")
	log.Debug(r.Form, "repo", repo)
	h := &task.JobHelper{Server: s.Server, ExecutorUrls: s.ExecutorUrls}
	job := h.BuildRepoJob(repo)
	if err := h.CreateJob(job); err != nil {
		http.Error(w, errors.ErrorStack(err), http.StatusInternalServerError)
		return
	}

	log.Debugf("%+v", job)

	if err := h.RunJob(job); err != nil {
		http.Error(w, errors.ErrorStack(err), http.StatusInternalServerError)
		return
	}
}
開發者ID:ngaut,項目名稱:dronecluster,代碼行數:27,代碼來源:api.go

示例11: SetPK

func (ti *TableInfo) SetPK(colnames []string) error {
	log.Debugf("table %s SetPK %s", ti.Name, colnames)
	pkIndex := schema.NewIndex("PRIMARY")
	colnums := make([]int, len(colnames))
	for i, colname := range colnames {
		colnums[i] = ti.FindColumn(strings.ToLower(colname))
		if colnums[i] == -1 {
			return errors.Errorf("column %s not found, %+v", colname, ti.Columns)
		}
		pkIndex.AddColumn(strings.ToLower(colname), 1)
	}

	for _, col := range ti.Columns {
		pkIndex.DataColumns = append(pkIndex.DataColumns, strings.ToLower(col.Name))
	}

	if len(ti.Indexes) == 0 {
		ti.Indexes = make([]*schema.Index, 1)
	} else if ti.Indexes[0].Name != "PRIMARY" {
		ti.Indexes = append(ti.Indexes, nil)
		copy(ti.Indexes[1:], ti.Indexes[:len(ti.Indexes)-1])
	} // else we replace the currunt primary key

	ti.Indexes[0] = pkIndex
	ti.PKColumns = colnums
	return nil
}
開發者ID:sdgdsffdsfff,項目名稱:cm,代碼行數:27,代碼來源:table_info.go

示例12: removeWorker

func (self *Server) removeWorker(l *list.List, sessionId int64) {
	for it := l.Front(); it != nil; it = it.Next() {
		if it.Value.(*Worker).SessionId == sessionId {
			log.Debugf("removeWorker sessionId %d", sessionId)
			l.Remove(it)
			return
		}
	}
}
開發者ID:UGuarder,項目名稱:gearmand,代碼行數:9,代碼來源:server.go

示例13: PingServer

func PingServer(checker AliveChecker, errCtx interface{}, errCh chan<- interface{}) {
	err := checker.CheckAlive()
	log.Debugf("check %+v, result:%v, errCtx:%+v", checker, err, errCtx)
	if err != nil {
		errCh <- errCtx
		return
	}
	errCh <- nil
}
開發者ID:cuiwm,項目名稱:codis-ha,代碼行數:9,代碼來源:servergroup.go

示例14: readInitialHandshake

func (c *MySqlConn) readInitialHandshake() error {
	data, err := c.readPacket()
	if err != nil {
		return err
	}

	if data[0] == ERR_HEADER {
		return errors.Trace(err)
	}

	if data[0] < MinProtocolVersion {
		return errors.Errorf("invalid protocol version %d, must >= 10", data[0])
	}

	//skip mysql version and connection id
	//mysql version end with 0x00
	//connection id length is 4
	pos := 1 + bytes.IndexByte(data[1:], 0x00) + 1 + 4

	c.salt = append(c.salt, data[pos:pos+8]...)

	//skip filter
	pos += 8 + 1

	//capability lower 2 bytes
	c.capability = uint32(binary.LittleEndian.Uint16(data[pos : pos+2]))

	pos += 2

	if len(data) > pos {
		//skip server charset
		//c.charset = data[pos : pos+1]
		log.Debugf("charset %+v", data[pos:pos+1])
		pos++

		c.status = binary.LittleEndian.Uint16(data[pos : pos+2])
		pos += 2

		c.capability = uint32(binary.LittleEndian.Uint16(data[pos:pos+2]))<<16 | c.capability

		pos += 2

		//skip auth data len or [00]
		//skip reserved (all [00])
		pos += 10 + 1

		// The documentation is ambiguous about the length.
		// The official Python library uses the fixed length 12
		// mysql-proxy also use 12
		// which is not documented but seems to work.
		c.salt = append(c.salt, data[pos:pos+12]...)
	}

	return nil
}
開發者ID:sdgdsffdsfff,項目名稱:cm,代碼行數:55,代碼來源:conn.go

示例15: handleMesosStatusUpdate

func (self *ResMan) handleMesosStatusUpdate(t *cmdMesosStatusUpdate) {
	status := t.status

	defer func() {
		t.wait <- struct{}{}
	}()

	taskId := status.TaskId.GetValue()
	log.Debugf("Received task %+v status: %+v", taskId, status)
	currentTask := self.running.Get(taskId)
	if currentTask == nil {
		task, err := scheduler.GetTaskByTaskId(taskId)
		if err != nil {
			return
		}
		job, err := scheduler.GetJobByName(task.JobName)
		if err != nil {
			return
		}
		currentTask = &Task{Tid: task.TaskId, job: job, SlaveId: status.SlaveId.GetValue(), state: taskRuning}
		self.running.Add(currentTask.Tid, currentTask) //add this alone task to runing queue
	}

	pwd := string(status.Data)
	if len(pwd) > 0 && len(currentTask.Pwd) == 0 {
		currentTask.Pwd = pwd
	}

	currentTask.LastUpdate = time.Now()

	switch *status.State {
	case mesos.TaskState_TASK_FINISHED:
		currentTask.job.LastSuccessTs = time.Now().Unix()
		self.removeRunningTask(taskId)
	case mesos.TaskState_TASK_FAILED, mesos.TaskState_TASK_KILLED, mesos.TaskState_TASK_LOST:
		currentTask.job.LastErrTs = time.Now().Unix()
		self.removeRunningTask(taskId)
	case mesos.TaskState_TASK_STAGING:
		//todo: update something
	case mesos.TaskState_TASK_STARTING:
		//todo:update something
	case mesos.TaskState_TASK_RUNNING:
		//todo:update something
	default:
		log.Fatalf("should never happend %+v", status.State)
	}

	persistentTask, err := scheduler.GetTaskByTaskId(taskId)
	if err != nil {
		log.Error(err)
	}

	self.saveTaskStatus(persistentTask, status, currentTask)
}
開發者ID:NextMark,項目名稱:tyrant,代碼行數:54,代碼來源:scheduler.go


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