• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang clog.Println函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getBatchDelTagsName

func getBatchDelTagsName(reponame, itemname, tagname string) ([]string, error) {
	log.Println("Batch delete tags from db")
	sqlrpdmid := fmt.Sprintf(`SELECT RPDMID FROM DH_DP_RPDM_MAP WHERE REPOSITORY='%s' AND DATAITEM='%s' AND STATUS='A';`, reponame, itemname)
	var rpdmId int

	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 nil, err
	}
	row.Scan(&rpdmId)

	tagname = strings.Replace(tagname, "*", "%", -1)
	log.Println(tagname)
	sql := fmt.Sprintf(`SELECT TAGNAME FROM DH_RPDM_TAG_MAP WHERE TAGNAME LIKE '%s' AND RPDMID=%d AND STATUS='A';`, tagname, rpdmId)
	//var tagnames []string
	tagsname := make([]string, 0)
	rows, err := g_ds.QueryRows(sql)
	if err != nil {
		l := log.Error("batch delete tag from DH_RPDM_TAG_MAP error:", err)
		logq.LogPutqueue(l)
		return nil, err
	}
	for rows.Next() {
		rows.Scan(&tagname)
		tagsname = append(tagsname, tagname)
	}
	log.Println(tagsname)
	/*if len(tagsname) == 0 {
		return nil, errors.New("没有匹配的tag")
	}*/
	return tagsname, nil

}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:35,代码来源:common.go


示例2: DeleteItemOrTag

func DeleteItemOrTag(repo, item, tag string) (err error) {
	uri := "/repositories/"
	if len(tag) == 0 {
		uri = uri + repo + "/" + item
	} else {
		uri = uri + repo + "/" + item + "/" + tag
	}
	log.Println(uri)
	req, err := http.NewRequest("DELETE", DefaultServerAPI+uri, nil)
	if len(loginAuthStr) > 0 {
		req.Header.Set("Authorization", loginAuthStr)
	}
	if err != nil {
		return err
	}
	//req.Header.Set("User", "admin")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	if resp.StatusCode == http.StatusOK {
		return nil
	} else {
		body, _ := ioutil.ReadAll(resp.Body)
		log.Println(resp.StatusCode, string(body))
		return errors.New(fmt.Sprintf("%d", resp.StatusCode))
	}
	return err
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:31,代码来源:pub_handler.go


示例3: GetTagComment

func GetTagComment(repo, item, tag string) string {
	path := "/api/repositories/" + repo + "/" + item + "/" + tag

	resp, err := commToServerGetRsp("get", path, nil)
	if err != nil {
		log.Error(err)
		return ""
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusBadRequest {
		err = errors.New("unkown error")
		log.Error("GET", path, resp.StatusCode)
		return ""
	}
	result := ds.Response{}
	struComment := &struct {
		Comment string `json:"comment"`
	}{}
	result.Data = struComment

	respbody, _ := ioutil.ReadAll(resp.Body)
	log.Println(string(respbody))
	unmarshalerr := json.Unmarshal(respbody, &result)
	if unmarshalerr != nil {
		log.Error(unmarshalerr)
		return ""
	}
	log.Println(result)

	return struComment.Comment
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:32,代码来源:pull_handler.go


示例4: checkAccessToken

func checkAccessToken(tokenUrl string) (bool, string) {
	log.Println("daemon: connecting to", DefaultServerAPI+tokenUrl)
	req, err := http.NewRequest("GET", DefaultServerAPI+tokenUrl, nil)
	if len(loginAuthStr) > 0 {
		req.Header.Set("Authorization", loginAuthStr)
	}

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return false, ""
	}
	defer resp.Body.Close()

	body, _ := ioutil.ReadAll(resp.Body)

	type tokenDs struct {
		Valid bool `json:"valid"`
	}
	tkresp := tokenDs{}
	result := &ds.Result{Data: &tkresp}
	if err = json.Unmarshal(body, &result); err != nil {
		log.Println(err)
		return false, ""
	}
	log.Trace(string(body))

	return tkresp.Valid, result.Msg
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:28,代码来源:p2pserver.go


示例5: RollBackTag

func RollBackTag(repo, item, tag string) {
	//Delete /repository/repo/item tag
	log.Println(repo, "/", item, ":", tag)
	err := DeleteItemOrTag(repo, item, tag)
	if err != nil {
		log.Println("DeleteTag err ", err.Error())
	}
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:8,代码来源:pub_handler.go


示例6: RollBackItem

func RollBackItem(repo, item string) {
	//Delete /repository/repo/item
	log.Println(repo, "/", item)
	err := DeleteItemOrTag(repo, item, "")
	if err != nil {
		log.Println("DeleteItem err ", err.Error())
	}
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:8,代码来源:pub_handler.go


示例7: rollbackDelTag

func rollbackDelTag(tagid int) error {
	log.Println("TODO rollback delete tag from db")
	log.Println(tagid)
	sql := fmt.Sprintf(`UPDATE DH_RPDM_TAG_MAP SET STATUS='A' WHERE TAGID=%d`, tagid)
	_, err := g_ds.Update(sql)
	if err != nil {
		l := log.Error("rollback delete tag error:", err)
		logq.LogPutqueue(l)
		return err
	}
	return nil
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:12,代码来源:common.go


示例8: GetDataPoolStatusByID

func GetDataPoolStatusByID(dpid int) (status string) {
	sqlGetDpStatus := fmt.Sprintf("SELECT STATUS FROM DH_DP WHERE DPID=%d", dpid)
	row, err := g_ds.QueryRow(sqlGetDpStatus)
	if err != nil {
		log.Println(sqlGetDpStatus)
		log.Println(err.Error())
		return
	}
	row.Scan(&status)
	if status != "A" {
		log.Println("dpid:", dpid, " status:", status)
	}
	return
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:14,代码来源:common.go


示例9: GetSampleData

func GetSampleData(itempath string) (sample string) {
	var filename string
	for _, v := range SampleFiles {
		filename = itempath + "/" + v
		if isFileExists(filename) == true {
			if bytes, err := ioutil.ReadFile(filename); err == nil {
				sample = string(bytes)
				return sample
			} else {
				l := log.Error(err)
				logq.LogPutqueue(l)
			}
		}
	}
	d, err := os.Open(itempath) //ppen dir
	if err != nil {
		log.Println(err)
		return ""
	}
	defer d.Close()
	ff, _ := d.Readdir(10) //  return []fileinfo
	for i, fi := range ff {
		log.Printf("sample filename %d: %+v\n", i, fi.Name())
		filename = strings.ToLower(fi.Name())
		if filename != "sample.md" && filename != "meta.md" && filename != PriceFile {
			f, err := os.Open(itempath + "/" + fi.Name())
			log.Println("filename:", itempath+"/"+fi.Name())
			if err != nil {
				continue
			}
			defer f.Close()
			scanner := bufio.NewScanner(f)
			scanner.Split(bufio.ScanLines)
			var i = 0
			for scanner.Scan() {
				if i > 9 {
					break
				}
				i++
				sample += scanner.Text() + "  \n" //md "  \n" is a new line
				//log.Println(scanner.Text())
			}
			break
		}
	}
	log.Debug("sample data:", sample)
	//need lenth check
	return sample
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:49,代码来源:pub_handler.go


示例10: InsertItemToDb

func InsertItemToDb(repo, item, datapool, itemdesc, createTime string) (err error) {
	log.Println("Insert item to db")
	dpid := GetDataPoolDpid(datapool)
	if dpid > 0 {
		//sqlInsertItem := fmt.Sprintf(`INSERT INTO DH_DP_RPDM_MAP (RPDMID, REPOSITORY, DATAITEM, ITEMDESC, DPID, PUBLISH, CREATE_TIME, STATUS)
		//	VALUES (null, '%s', '%s', '%s', %d, 'Y',  datetime('now'), 'A')`, repo, item, itemdesc, dpid)
		sqlInsertItem := fmt.Sprintf(`INSERT INTO DH_DP_RPDM_MAP (RPDMID, REPOSITORY, DATAITEM, ITEMDESC, DPID, PUBLISH, CREATE_TIME, STATUS)
			VALUES (null, '%s', '%s', '%s', %d, 'Y', '%s', 'A')`, repo, item, itemdesc, dpid, createTime)
		_, err = g_ds.Insert(sqlInsertItem)
		log.Println(sqlInsertItem)

	} else {
		err = errors.New("dpid is not found")
	}
	return err
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:16,代码来源:common.go


示例11: InsertTagToDb

func InsertTagToDb(dpexist bool, p ds.DsPull, tagcom string) (err error) {
	if dpexist == false {
		return
	}
	DpId := GetDataPoolDpid(p.Datapool)
	if DpId == 0 {
		return
	}
	rpdmid := GetRepoItemId(p.Repository, p.Dataitem)

	if rpdmid == 0 {
		sqlInsertRpdm := fmt.Sprintf(`INSERT INTO DH_DP_RPDM_MAP
			(RPDMID ,REPOSITORY, DATAITEM, DPID, PUBLISH ,CREATE_TIME ,STATUS, ITEMDESC) 
		    VALUES (null, '%s', '%s', %d, 'N', datetime('now'), 'A', '%s')`,
			p.Repository, p.Dataitem, DpId, p.ItemDesc)
		g_ds.Insert(sqlInsertRpdm)
		rpdmid = GetRepoItemId(p.Repository, p.Dataitem)
	}
	sqlInsertTag := fmt.Sprintf(`INSERT INTO DH_RPDM_TAG_MAP(TAGID, TAGNAME ,RPDMID ,DETAIL,CREATE_TIME, STATUS, COMMENT) 
		VALUES (null, '%s', %d, '%s', datetime('now'), 'A', '%s')`,
		p.Tag, rpdmid, p.DestName, tagcom)
	log.Println(sqlInsertTag)
	_, err = g_ds.Insert(sqlInsertTag)
	return err
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:25,代码来源:common.go


示例12: dl

func dl(uri, ip string, p ds.DsPull, w http.ResponseWriter, c chan int) error {

	if len(ip) == 0 {
		ip = "http://localhost:65535"
		//TODO return
	}

	target := ip + uri
	log.Println(target)
	n, err := download(target, p, w, c)
	if err != nil {
		log.Printf("[%d bytes returned.]\n", n)
		log.Println(err)
	}
	return err
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:16,代码来源:pull_handler.go


示例13: 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
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:27,代码来源:common.go


示例14: 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)
		}
	}
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:26,代码来源:common.go


示例15: repoItemHandler

func repoItemHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
	log.Println(r.URL.Path, "(repo/item)")
	reqBody, _ := ioutil.ReadAll(r.Body)
	commToServer("get", r.URL.Path+"?size=-1", reqBody, w)

	return
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:7,代码来源:repo_handler.go


示例16: stopHttp

func stopHttp(rw http.ResponseWriter, req *http.Request) {
	rw.WriteHeader(http.StatusOK)
	//fmt.Fprintf(rw, "Hello HTTP!\n")
	sl.Close()
	p2psl.Close()
	log.Println("connect close")
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:7,代码来源:daemon.go


示例17: 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)
		}
	}
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:26,代码来源:common.go


示例18: delTag

func delTag(reponame, itemname, tagname string) (int, error) {
	log.Println("TODO  delete tag from db")
	sqlrpdmid := fmt.Sprintf(`SELECT RPDMID FROM DH_DP_RPDM_MAP WHERE REPOSITORY='%s' AND DATAITEM='%s' AND STATUS='A';`, reponame, itemname)
	var rpdmId int
	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 0, err
	}
	row.Scan(&rpdmId)

	sql := fmt.Sprintf(`SELECT TAGID FROM DH_RPDM_TAG_MAP WHERE STATUS='A' AND TAGNAME='%s' AND RPDMID=%d`, tagname, rpdmId)
	var tagid int
	row, err = g_ds.QueryRow(sql)
	if err != nil {
		l := log.Error("select tagid from DH_DP_RPDM_MAP error:", err)
		logq.LogPutqueue(l)
		return 0, err
	}
	row.Scan(&tagid)

	sql = fmt.Sprintf(`UPDATE DH_RPDM_TAG_MAP SET STATUS='N' WHERE TAGNAME='%s' AND RPDMID=%d`, tagname, rpdmId)
	_, err = g_ds.Update(sql)
	if err != nil {
		l := log.Error("delete tag from DH_RPDM_TAG_MAP error:", err)
		logq.LogPutqueue(l)
		return 0, err
	}

	return tagid, nil
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:32,代码来源:common.go


示例19: delEntryPoint

func delEntryPoint() {
	log.Println("TODO remove ep from db.")
	d := `UPDATE DH_DAEMON SET ENTRYPOINT = '';`
	if _, e := g_ds.Update(d); e != nil {
		l := log.Error(d, "error.", e)
		logq.LogPutqueue(l)
	}
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:8,代码来源:common.go


示例20: InsertPubTagToDb

func InsertPubTagToDb(repo, item, tag, fileName, comment string) (err error) {
	log.Println("Insert pub tag to db.")
	rpdmid := GetRepoItemId(repo, item)
	if rpdmid == 0 {
		return errors.New("Dataitem is not found which need to be published before publishing tag. ")
	}
	sqlInsertTag := fmt.Sprintf("INSERT INTO DH_RPDM_TAG_MAP (TAGID, TAGNAME, RPDMID, DETAIL, CREATE_TIME, STATUS, COMMENT) VALUES (null, '%s', %d, '%s', datetime('now'), 'A', '%s');", tag, rpdmid, fileName, comment)
	log.Println(sqlInsertTag)
	_, err = g_ds.Insert(sqlInsertTag)
	if err != nil {
		l := log.Error("Insert tag into db error:", err)
		logq.LogPutqueue(l)
		return err
	}

	return
}
开发者ID:asiainfoLDP,项目名称:datahub,代码行数:17,代码来源:common.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang logq.LogPutqueue函数代码示例发布时间:2022-05-24
下一篇:
Golang clog.Info函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap