本文整理汇总了Golang中github.com/asiainfoLDP/datahub/utils/clog.Debug函数的典型用法代码示例。如果您正苦于以下问题:Golang Debug函数的具体用法?Golang Debug怎么用?Golang Debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: saveEntryPoint
func saveEntryPoint(ep string) {
log.Println("TODO save ep to db")
count := `SELECT COUNT(*) FROM DH_DAEMON;`
row, err := g_ds.QueryRow(count)
if err != nil {
l := log.Error(count, "error.", err)
logq.LogPutqueue(l)
}
var c int
row.Scan(&c)
if c > 0 {
Update := fmt.Sprintf(`UPDATE DH_DAEMON SET ENTRYPOINT='%s';`, ep)
log.Debug(Update)
if _, e := g_ds.Update(Update); e != nil {
l := log.Error(Update, "error.", e)
logq.LogPutqueue(l)
}
} else {
Insert := fmt.Sprintf(`INSERT INTO DH_DAEMON (ENTRYPOINT) VALUES ('%s');`, ep)
log.Debug(c, Insert)
if _, e := g_ds.Insert(Insert); e != nil {
l := log.Error(Insert, "error.", e)
logq.LogPutqueue(l)
}
}
}
示例2: saveDaemonID
func saveDaemonID(id string) {
log.Println("TODO save daemonid to db when srv returns code 0.")
count := `SELECT COUNT(*) FROM DH_DAEMON;`
row, err := g_ds.QueryRow(count)
if err != nil {
l := log.Error(count, "error.", err)
logq.LogPutqueue(l)
}
var c int
row.Scan(&c)
if c > 0 {
Update := fmt.Sprintf(`UPDATE DH_DAEMON SET DAEMONID='%s';`, id)
log.Debug(Update)
if _, e := g_ds.Update(Update); e != nil {
l := log.Error(Update, "error.", e)
logq.LogPutqueue(l)
}
} else {
Insert := fmt.Sprintf(`INSERT INTO DH_DAEMON (DAEMONID) VALUES ('%s');`, id)
log.Debug(c, Insert)
if _, e := g_ds.Insert(Insert); e != nil {
l := log.Error(Insert, "error.", e)
logq.LogPutqueue(l)
}
}
}
示例3: publishedOfDatapoolHandler
func publishedOfDatapoolHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
log.Debug(r.URL.Path, "published of a datapool", r)
r.ParseForm()
datapool := ps.ByName("dpname")
status := "published"
count := getRepoCountByDp(datapool, status)
offset, limit := optionalOffsetAndSize(r, 10, 1, 100)
log.Debug("offset, limit", offset, limit)
validateOffsetAndLimit(count, &offset, &limit)
repoInfos, err := GetRepoInfo(datapool, status, offset, limit)
log.Debug(repoInfos, offset, limit)
if err != nil {
log.Error(err)
JsonResult(w, http.StatusInternalServerError, cmd.InternalError, err.Error(), nil)
return
}
if len(repoInfos) == 0 {
msg := fmt.Sprintf("No published dataitem in %s.", datapool)
JsonResult(w, http.StatusOK, cmd.ErrorPublishedItemEmpty, msg, nil)
} else {
msg := fmt.Sprintf("Dataitems have been published into %s.", datapool)
JsonResult(w, http.StatusOK, cmd.ResultOK, msg, newQueryListResult(count, &repoInfos))
}
}
示例4: pulledOfRepoHandler
func pulledOfRepoHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
log.Debug(r.URL.Path, "item pulled of a repository")
r.ParseForm()
dpName := ps.ByName("dpname")
repoName := ps.ByName("repo")
isPublished := "N"
count := getItemCountByDpRepo(dpName, repoName, isPublished)
offset, limit := optionalOffsetAndSize(r, 10, 1, 100)
validateOffsetAndLimit(count, &offset, &limit)
pulledRepoItems, err := GetPulledRepoInfo(dpName, repoName, offset, limit)
if err != nil {
log.Debug(err)
JsonResult(w, http.StatusInternalServerError, cmd.InternalError, err.Error(), nil)
return
}
if len(pulledRepoItems) == 0 {
msg := fmt.Sprintf("Pulled DataItem of %s is empty.", repoName)
JsonResult(w, http.StatusOK, cmd.ErrorPublishedItemEmpty, msg, nil)
} else {
msg := fmt.Sprintf("All DataItems have been pulled of %s.", repoName)
JsonResult(w, http.StatusOK, cmd.ResultOK, msg, newQueryListResult(count, pulledRepoItems))
}
}
示例5: deleteItemsAccordingToHeartbeat
func deleteItemsAccordingToHeartbeat(body []byte) {
log.Debug("deleteItemsAccordingToHeartbeat() BEGIN:", string(body))
result := ds.Result{}
itemEvent := &Event{}
result.Data = itemEvent
itemsdelete := []ItemDel{}
itemEvent.Data = &itemsdelete
if err := json.Unmarshal(body, &result); err == nil {
log.Debug("items delete:", itemsdelete)
for _, v := range itemsdelete {
log.Debugf("delete item according to heartbeat: %v/%v\n", v.Repname, v.Itemname)
err := delTagsForDelItem(v.Repname, v.Itemname)
if err != nil {
log.Error(err)
return
}
err = delItem(v.Repname, v.Itemname)
if err != nil {
log.Error(err)
return
}
log.Infof("Delete data item %v/%v according to heartbeat successfully.\n", v.Repname, v.Itemname)
}
} else {
log.Warn("Unmarshal error:", err)
}
}
示例6: publishedTagOfItemHandler
func publishedTagOfItemHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
log.Debug(r.URL.Path, "tags published of dataitem")
r.ParseForm()
dpname := ps.ByName("dpname")
repo := ps.ByName("repo")
item := ps.ByName("item")
count, err := getPublishedTagCount(dpname, repo, item)
if err != nil {
log.Debug(err)
JsonResult(w, http.StatusInternalServerError, cmd.InternalError, err.Error(), nil)
return
}
offset, limit := optionalOffsetAndSize(r, 10, 1, 100)
log.Debug("offset, limit", offset, limit)
validateOffsetAndLimit(count, &offset, &limit)
publishedTagsOfItem, err := GetPublishedTagsOfItemInfo(dpname, repo, item, offset, limit)
if err != nil {
log.Debug(err)
JsonResult(w, http.StatusInternalServerError, cmd.InternalError, err.Error(), nil)
return
}
if len(publishedTagsOfItem) == 0 {
msg := fmt.Sprintf("Published tags of %s/%s is empty.", repo, item)
JsonResult(w, http.StatusOK, cmd.ErrorPulledTagEmpty, msg, nil)
} else {
msg := fmt.Sprintf("All tags have been published of %s/%s", repo, item)
JsonResult(w, http.StatusOK, cmd.ResultOK, msg, newQueryListResult(count, &publishedTagsOfItem))
}
}
示例7: optionalIntParamInQuery
func optionalIntParamInQuery(r *http.Request, paramName string, defaultInt int64) int64 {
if r.Form.Get(paramName) == "" {
log.Debug("paramName nil", paramName, r.Form)
return defaultInt
}
i, err := strconv.ParseInt(r.Form.Get(paramName), 10, 64)
if err != nil {
log.Debug("ParseInt", err)
return defaultInt
} else {
return i
}
}
示例8: getRepoCountByDp
func getRepoCountByDp(datapool, status string) int64 {
if status == "published" {
status = "Y"
} else {
status = "N"
}
sql := fmt.Sprintf(`SELECT COUNT(DISTINCT REPOSITORY)
FROM DH_DP_RPDM_MAP
WHERE DPID IN
(SELECT DPID FROM DH_DP WHERE DPNAME = '%s' AND STATUS='A')
AND PUBLISH= '%s'
AND STATUS = 'A';`, datapool, status)
row, err := g_ds.QueryRow(sql)
if err != nil {
l := log.Error(err)
logq.LogPutqueue(l)
return 0
}
var count int64
row.Scan(&count)
log.Debug("Published repository count:", count)
return count
}
示例9: getPulledTagCount
func getPulledTagCount(datapool, repo, item string) (int64, error) {
sql := fmt.Sprintf(`SELECT COUNT(*)
FROM DH_RPDM_TAG_MAP
WHERE RPDMID = (SELECT RPDMID FROM DH_DP_RPDM_MAP
WHERE REPOSITORY = '%s'
AND DATAITEM = '%s'
AND PUBLISH = 'N'
AND STATUS = 'A'
AND DPID = (SELECT DPID FROM DH_DP WHERE DPNAME = '%s' AND STATUS='A'))
AND STATUS = 'A';`, repo, item, datapool)
row, err := g_ds.QueryRow(sql)
if err != nil {
l := log.Error(err)
logq.LogPutqueue(l)
return 0, err
}
var count int64
row.Scan(&count)
log.Debug("Published repository count:", count)
return count, err
}
示例10: GetDaemonRoleByPubRecord
func GetDaemonRoleByPubRecord() (role int) {
sql := `SELECT COUNT(*) FROM DH_DP_RPDM_MAP WHERE PUBLISH='Y' AND STATUS='A'
AND DPID IN (SELECT DPID FROM DH_DP WHERE STATUS='A');`
row := g_ds.Db.QueryRow(sql)
var count int
row.Scan(&count)
if count > 0 {
role = PUBLISHER
log.Debug("This datahub daemon is a publisher.")
} else {
role = PULLER
log.Debug("This datahub daemon is a puller.")
}
return
}
示例11: delTagsForDelItem
func delTagsForDelItem(reponame, itemname string) error {
log.Println("Begin to remove tags for remove item from db")
sqlrpdmid := fmt.Sprintf(`SELECT RPDMID FROM DH_DP_RPDM_MAP WHERE REPOSITORY='%s' AND DATAITEM='%s' AND STATUS='A';`, reponame, itemname)
row, err := g_ds.QueryRow(sqlrpdmid)
if err != nil {
l := log.Error("select rpdmid from DH_DP_RPDM_MAP error:", err)
logq.LogPutqueue(l)
return err
}
var rpdmId int
row.Scan(&rpdmId)
if rpdmId == 0 {
log.Debug(reponame, itemname, "not exist.")
return nil
}
sqldeltag := fmt.Sprintf(`UPDATE DH_RPDM_TAG_MAP SET STATUS='N' WHERE RPDMID=%d`, rpdmId)
_, err = g_ds.Update(sqldeltag)
log.Info("sqldeltag", sqldeltag)
if err != nil {
l := log.Error("delete tag error:", err)
logq.LogPutqueue(l)
return err
}
return nil
}
示例12: CheckHealthClock
func CheckHealthClock() {
log.Debug("--------->BEGIN")
checkHealth(&Errortagsmap)
timer := time.NewTicker(10 * time.Minute)
for {
select {
case <-timer.C:
now := time.Now()
if now.Hour()%6 == 0 {
log.Info("Time:", now)
checkHealth(&Errortagsmap)
}
}
}
log.Debug("---------->END")
}
示例13: removeAllJobDB
func removeAllJobDB() (e error) {
log.Debug("TODO remove all jobs from db")
sRmJobs := `DELETE FROM DH_JOB;`
_, e = g_ds.Delete(sRmJobs)
if e != nil {
l := log.Error(e)
logq.LogPutqueue(l)
}
return
}
示例14: removeJobDB
func removeJobDB(job *ds.JobInfo) (e error) {
log.Debug("TODO remove jobid from db")
sRmJob := fmt.Sprintf(`DELETE FROM DH_JOB WHERE JOBID=%d;`, job.ID)
_, e = g_ds.Delete(sRmJob)
if e != nil {
l := log.Error(e)
logq.LogPutqueue(l)
}
return
}
示例15: GetItemslocationInDatapool
func GetItemslocationInDatapool(itemslocation map[string]string, dpname string, dpid int, dpconn string) error {
sql := fmt.Sprintf("SELECT DISTINCT ITEMDESC, REPOSITORY, DATAITEM FROM DH_DP_RPDM_MAP WHERE DPID=%v AND STATUS='A';", dpid)
log.Debug(sql)
rows, err := g_ds.QueryRows(sql)
if err != nil {
l := log.Errorf("datapool name %s, dpid %v, dpconn %v, error:%v", dpname, dpid, dpconn, err)
logq.LogPutqueue(l)
return err
}
var location, repo, item string
for rows.Next() {
rows.Scan(&location, &repo, &item)
log.Debug(location, repo, item)
itemslocation[location] = repo + "/" + item
}
log.Trace(itemslocation)
return err
}