当前位置: 首页>>代码示例>>Golang>>正文


Golang loghttp.BuffLoggerUniversal函数代码示例

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


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

示例1: MimeFromBase64

// we want to extract the 'image/png' from
// 	"data:image/png;base64,..."
//func MimeFromBase64(b *bytes.Buffer)(mime string){
func MimeFromBase64(b io.Reader) (mime string) {

	lg, b := loghttp.BuffLoggerUniversal(nil, nil)
	_ = b

	// to avoid huge string allocation
	//   we read the first 100 bytes
	b1 := make([]byte, 100)
	_, err := b.Read(b1)
	lg(err)

	s := string(b1)

	pos := base64HeaderPosition(s)

	if pos > 0 {
		tmp1 := s[:pos]
		tmp2 := strings.Split(tmp1, ";")
		tmp3 := strings.Split(tmp2[0], ":")
		mime = tmp3[1]
	}

	return

}
开发者ID:aarzilli,项目名称:tools,代码行数:28,代码来源:conv_img_str.go

示例2: rssDoc2DirTree

func rssDoc2DirTree(w http.ResponseWriter, r *http.Request, treeX *DirTree, rssDoc RSS, domain string) {

	lg, lge := loghttp.Logger(w, r)
	_ = lg

	if treeX == nil {
		treeX = &DirTree{Name: "root1", Dirs: map[string]DirTree{}, LastFound: time.Now().Truncate(time.Minute)}
	}

	articleList := []FullArticle{}

	for _, lpItem := range rssDoc.Items.ItemList {

		t, err := time.Parse(time.RFC1123Z, lpItem.Published)
		//     := time.Parse("Mon, 2 Jan 2006 15:04:05 -0700", lpItem.Published)
		lge(err)

		articleList = append(articleList, FullArticle{Url: lpItem.Link, Mod: t})

	}

	lg1, _ := loghttp.BuffLoggerUniversal(w, r)

	path2DirTree(lg1, treeX, articleList, domain, true)

}
开发者ID:aarzilli,项目名称:tools,代码行数:26,代码来源:5_rss_fetch.go

示例3: GetHomeTpl

func GetHomeTpl(w http.ResponseWriter, r *http.Request, title, body string) *template.Template {

	if body == "" {
		body = IDCardHTML + UserInfoHTML
	}

	lg, _ := loghttp.BuffLoggerUniversal(w, r)

	bstpl := tplx.TemplateFromHugoPage(w, r)

	b := new(bytes.Buffer)

	fmt.Fprintf(b, tplx.ExecTplHelper(bstpl, map[string]interface{}{
		// "HtmlTitle":       "{{ .HtmlTitle }}", // this seems to cause problems sometimes.
		"HtmlTitle":       title,
		"HtmlDescription": "", // reminder
		"HtmlHeaders":     template.HTML(Headers),
		"HtmlContent":     template.HTML(body),
	}))

	intHomeTemplate, err := template.New("home").Parse(b.String())
	lg(err)

	return intHomeTemplate

}
开发者ID:aarzilli,项目名称:tools,代码行数:26,代码来源:tpl_creation.go

示例4: queuePush

func queuePush(w http.ResponseWriter, r *http.Request, mx map[string]interface{}) {

	lg, b := loghttp.BuffLoggerUniversal(w, r)
	_ = b

	c := appengine.NewContext(r)

	m := map[string][]string{"counter_name": []string{nscStringKey}}
	t := taskqueue.NewPOSTTask("/_ah/namespaced-counters/queue-pop", m)

	taskqueue.Add(c, t, "")

	c, err := appengine.Namespace(c, altNamespace)
	lg(err)
	taskqueue.Add(c, t, "")

	io.WriteString(w, "tasks enqueued\n")

	io.WriteString(w, "\ncounter values now: \n")
	readBothNamespaces(w, r, mx)

	io.WriteString(w, "\n\n...sleeping... \n")
	time.Sleep(time.Duration(400) * time.Millisecond)
	readBothNamespaces(w, r, mx)

}
开发者ID:aarzilli,项目名称:tools,代码行数:26,代码来源:namespace+taskqueue+ioWriteString.go

示例5: StringToVByte

// unused
// probably  efficient enough just to call
// var bEnc []byte = []byte(sEnc)
func StringToVByte(s string) (*bytes.Buffer, *bytes.Buffer) {

	lg, b := loghttp.BuffLoggerUniversal(nil, nil)
	_ = b

	bMsg := new(bytes.Buffer)

	bDst := new(bytes.Buffer)

	const chunksize = 20
	lb := make([]byte, chunksize) // loop buffer
	rdr := strings.NewReader(s)
	for {
		n1, err := rdr.Read(lb)
		if err == io.EOF {
			break
		}
		lg(err)
		if n1 < 1 {
			break
		}

		independentCopy := make([]byte, n1)
		copy(independentCopy, lb)
		n2, err := bDst.Write(independentCopy)
		lg(err)

		bMsg.WriteString(fmt.Sprintln("reading", n1, "bytes - writing", n2, "bytes: \n"))
		bMsg.WriteString(fmt.Sprint(" --", string(independentCopy), "--<br>\n"))
	}

	return bDst, bMsg

}
开发者ID:aarzilli,项目名称:tools,代码行数:37,代码来源:image+save+and+retrieve.go

示例6: readBothNamespaces

func readBothNamespaces(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	lg, b := loghttp.BuffLoggerUniversal(w, r)
	_ = b

	var c1, c2 int64
	var s1, s2 string
	var err error
	var reset bool = false

	p := r.FormValue("reset")
	if p != "" {
		reset = true
	}

	c := appengine.NewContext(r)
	c1, err = agnosticReadReset(c, reset)
	lg(err)

	{
		c, err = appengine.Namespace(c, altNamespace)
		lg(err)
		c2, err = agnosticReadReset(c, reset)
		lg(err)
	}

	s1 = fmt.Sprintf("%v", c1)
	s2 = fmt.Sprintf("%v", c2)

	io.WriteString(w, "|"+s1+"|    |"+s2+"|")
	if reset {
		io.WriteString(w, "     and reset")
	}

}
开发者ID:aarzilli,项目名称:tools,代码行数:35,代码来源:namespace+taskqueue+ioWriteString.go

示例7: searchPut

func searchPut(w http.ResponseWriter, r *http.Request) {

	lg, b := loghttp.BuffLoggerUniversal(w, r)
	_ = b

	id := "PA6-5001"
	user := &User{
		Customer:  "Carl Corral",
		Comment:   "I am <em>riled up</em> text",
		Visits:    1,
		LastVisit: time.Now(),
		Birthday:  time.Date(1968, time.May, 19, 0, 0, 0, 0, time.UTC),
	}

	c := appengine.NewContext(r)

	index, err := search.Open("users")
	lg(err)

	ret_id, err := index.Put(c, id, user)
	lg(err)

	fmt.Fprint(w, "OK, saved "+ret_id+"\n\n")

	var u2 User
	err = index.Get(c, ret_id, &u2)
	lg(err)
	fmt.Fprint(w, "Retrieved document: ", u2)

}
开发者ID:aarzilli,项目名称:tools,代码行数:30,代码来源:fulltext_search.go

示例8: paymentSuccess

/*
https://tec-news.appspot.com/coinbase-integr/redir-success1?
order[button][description]=When and how Bitcoin decline will start.&
order[button][id]=0025d69ea925b48ba2b7adeb2a911ca2&
order[button][name]=Bitcoin Analysis&
order[button][repeat]=&
order[button][resource_path]=/v2/checkouts/4f1e5ecc-c8fc-56fc-926c-15a7eebd8314&
order[button][subscription]=false&
order[button][type]=buy_now&
order[button][uuid]=4f1e5ecc-c8fc-56fc-926c-15a7eebd8314&
order[created_at]=2015-10-26 08:03:17 -0700&
order[custom]=productID=/member/tec-news/crypto-experts-neglect-one-vital-aspect&uID=14952300052240127534&
order[event]=&
order[id]=GAB5VN36&
order[metadata]=&
order[receive_address]=myL84ofiymQpzzmJ7Foc9F2wQ4GMuSuQ3f&
order[refund_address]=mwaz3wxMbnZrBZUSZpVHr51xjQ6Swx756b&
order[resource_path]=/v2/orders/9bbf6fde-530a-53a4-bf94-d54fc3f43d40&
order[status]=completed&
order[total_btc][cents]=5600.0&
order[total_btc][currency_iso]=BTC&
order[total_native][cents]=50.0&
order[total_native][currency_iso]=EUR&
order[total_payout][cents]=0.0&
order[total_payout][currency_iso]=USD&
order[transaction][confirmations]=0&
order[transaction][hash]=ada26d75ff1e16b4febf539433d5260441171560c57adfff2ac968be37108112&
order[transaction][id]=562e40dede472f26be000018&
order[uuid]=9bbf6fde-530a-53a4-bf94-d54fc3f43d40
*/
func paymentSuccess(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	r.Header.Set("X-Custom-Header-Counter", "nocounter")
	lg, _ := loghttp.BuffLoggerUniversal(w, r)

	err := r.ParseForm()
	if err != nil {
		lg(err)
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	custom := r.Form.Get("order[custom]")
	// w.Write([]byte("custom=" + custom + "<br>\n"))

	values, err := url.ParseQuery(custom)
	if err != nil {
		lg(err)
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	productID := values.Get("productID")
	uID := values.Get("uID")

	if productID != "" {
		lg("about to redirect to %v", productID)
		http.Redirect(w, r, productID+"?redirected-from=paymentsucc", http.StatusFound)
		return
	}

	w.Write([]byte("productID=" + productID + " uID=" + uID + "<br>\n"))

}
开发者ID:aarzilli,项目名称:tools,代码行数:64,代码来源:coinbase.go

示例9: Dom2File

// Dom2File writes DOM to file
func Dom2File(fn string, node *html.Node) {
	lg, _ := loghttp.BuffLoggerUniversal(nil, nil)

	var b bytes.Buffer
	err := html.Render(&b, node)
	lg(err)
	Bytes2File(fn, b.Bytes())
}
开发者ID:aarzilli,项目名称:tools,代码行数:9,代码来源:file_io.go

示例10: queuePop

func queuePop(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	lg, b := loghttp.BuffLoggerUniversal(w, r)
	_ = b

	c := appengine.NewContext(r)
	err := agnosticIncrement(c)
	c.Infof("qp")
	lg(err)
}
开发者ID:aarzilli,项目名称:tools,代码行数:10,代码来源:namespace+taskqueue+ioWriteString.go

示例11: Base64_str_to_img

func Base64_str_to_img(base64_img string) (img image.Image, format string) {

	lg, b := loghttp.BuffLoggerUniversal(nil, nil)
	_ = b

	pos := base64HeaderPosition(base64_img)

	reader := base64.NewDecoder(base64.StdEncoding, strings.NewReader(base64_img[pos:]))
	img, format, err := image.Decode(reader)
	lg(err)
	return
}
开发者ID:aarzilli,项目名称:tools,代码行数:12,代码来源:conv_img_str.go

示例12: deleteAll

func deleteAll(w http.ResponseWriter, r *http.Request, m map[string]interface{}) {

	lg, _ := loghttp.BuffLoggerUniversal(w, r)

	err := r.ParseForm()
	lg(err)

	wpf(w, tplx.ExecTplHelper(tplx.Head, map[string]interface{}{"HtmlTitle": "Delete all filesystem data"}))
	defer wpf(w, tplx.Foot)

	confirm := r.FormValue("confirm")
	if confirm != "yes" {
		wpf(w, "All dsfs contents are deletes. All memfs contents are deleted<br>\n")
		wpf(w, "Put a get param into the URL ?confirm - and set it to 'yes'<br>\n")
		wpf(w, "Put a get param 'mountname' into url; i.e. mountname=mntftch<br>\n")
		return
	}

	wpf(w, "<pre>\n")
	defer wpf(w, "\n</pre>")

	//
	//
	fs := dsfs.New(
		dsfs.AeContext(appengine.NewContext(r)),
	)

	mountName := r.FormValue("mountname")
	if mountName != "" {
		wpf(w, "mountame = "+mountName+"\n")
		fs = dsfs.New(
			dsfs.AeContext(appengine.NewContext(r)),
			dsfs.MountName(mountName),
		)
	}

	wpf(w, "dsfs:\n")
	msg, err := fs.DeleteAll()
	if err != nil {
		wpf(w, "err during delete %v\n", err)
	}
	wpf(w, msg)

	memMapFileSys = memfs.New()
	wpf(w, "\n")
	wpf(w, "memMapFs new")

	// cleanup must be manual
	osFileSys = osfs.New()

}
开发者ID:aarzilli,项目名称:tools,代码行数:51,代码来源:spec_ops.go

示例13: Bytes2File

// Bytes2File writes bytes; creates path if neccessary
// and logs any errors even to appengine log
func Bytes2File(fn string, b []byte) {
	lg, _ := loghttp.BuffLoggerUniversal(nil, nil)

	var err error
	err = ioutil.WriteFile(fn, b, 0)
	if err != nil {

		err = os.MkdirAll(filepath.Dir(fn), os.ModePerm)
		lg(err, "directory creation failed: %v")

		err = ioutil.WriteFile(fn, b, 0)
		lg(err)

	}
}
开发者ID:aarzilli,项目名称:tools,代码行数:17,代码来源:file_io.go

示例14: VVByte_to_string

// based on bytes.Buffer and Writing into it
func VVByte_to_string(m [][]byte) (*bytes.Buffer, *bytes.Buffer) {

	lg, b := loghttp.BuffLoggerUniversal(nil, nil)
	_ = b

	bRet := new(bytes.Buffer)
	bMsg := new(bytes.Buffer)

	//for i,v := range m {
	for i := 0; i < len(m); i++ {
		n, err := bRet.Write(m[i])
		lg(err)
		bMsg.WriteString(" lp" + util.Itos(i) + ": writing " + util.Itos(n) + " bytes: \n")
	}
	return bRet, bMsg
}
开发者ID:aarzilli,项目名称:tools,代码行数:17,代码来源:conv_vvbyte.go

示例15: splitPort

func splitPort(hp string) string {

	lg, b := loghttp.BuffLoggerUniversal(nil, nil)
	_ = b

	host, port, err := net.SplitHostPort(hp)
	_ = port

	if err != nil {
		if strings.Contains(err.Error(), "missing port in address") {
			// normal
		} else {
			lg(err)
		}
		host = hp
	}

	return host
}
开发者ID:aarzilli,项目名称:tools,代码行数:19,代码来源:util.go


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