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


Golang seelog.Trace函數代碼示例

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


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

示例1: ReadAll

func (fr *TrecFileReader) ReadAll() <-chan Document {
	defer func() {
		if x := recover(); x != nil {
			log.Flush()
		}
	}()

	log.Trace("Reading documents")
	fr.scanner.Reset()
	log.Trace("Reset")
	go fr.read_to_chan(-1)
	return fr.documents
}
開發者ID:Georgetown-IR-Lab,項目名稱:ocr-correction,代碼行數:13,代碼來源:trec.go

示例2: NextScroll

func (s *ESAPIV0) NextScroll(scrollTime string, scrollId string) (*Scroll, error) {
	//  curl -XGET 'http://es-0.9:9200/_search/scroll?scroll=5m'
	id := bytes.NewBufferString(scrollId)
	url := fmt.Sprintf("%s/_search/scroll?scroll=%s&scroll_id=%s", s.Host, scrollTime, id)
	resp, body, errs := Get(url, s.Auth, s.HttpProxy)
	if errs != nil {
		log.Error(errs)
		return nil, errs[0]
	}

	if resp.StatusCode != 200 {
		return nil, errors.New(body)
	}

	defer resp.Body.Close()

	log.Trace("next scroll,", url, body)

	// decode elasticsearch scroll response
	scroll := &Scroll{}
	err := json.Unmarshal([]byte(body), &scroll)
	if err != nil {
		log.Error(body)
		log.Error(err)
		return nil, err
	}

	return scroll, nil
}
開發者ID:medcl,項目名稱:elasticsearch-migration,代碼行數:29,代碼來源:v0.go

示例3: dateTimeFormat

func dateTimeFormat() {
	fmt.Println("Date time format")

	testConfig := `
<seelog type="sync">
	<outputs formatid="main">
		<console/>
	</outputs>
	<formats>
		<format id="main" format="%Date/%Time [%LEV] %Msg%n"/>
	</formats>
</seelog>`

	logger, err := log.LoggerFromConfigAsBytes([]byte(testConfig))

	if err != nil {
		fmt.Println(err)
	}

	loggerErr := log.ReplaceLogger(logger)

	if loggerErr != nil {
		fmt.Println(loggerErr)
	}

	log.Trace("Test message!")
}
開發者ID:cihub,項目名稱:seelog-examples,代碼行數:27,代碼來源:formats_main.go

示例4: testFuncException

func testFuncException() {
	fmt.Println("testFuncException")
	testConfig := `
<seelog type="sync" minlevel="info">
	<exceptions>
		<exception funcpattern="*main.test*Except*" minlevel="error"/>
	</exceptions>
	<outputs>
		<console/>
	</outputs>
</seelog>`

	logger, _ := log.LoggerFromConfigAsBytes([]byte(testConfig))
	log.ReplaceLogger(logger)

	log.Trace("NOT Printed")
	log.Debug("NOT Printed")
	log.Info("NOT Printed")
	log.Warn("NOT Printed")
	log.Error("Printed")
	log.Critical("Printed")

	log.Current.Trace("NOT Printed")
	log.Current.Debug("NOT Printed")
	log.Current.Info("NOT Printed")
	log.Current.Warn("NOT Printed")
	log.Current.Error("Printed")
	log.Current.Critical("Printed")
}
開發者ID:cihub,項目名稱:seelog-examples,代碼行數:29,代碼來源:exceptions_main.go

示例5: doFetch

func (c *memcacheCacher) doFetch(sessId string) (u *User, cacheHit bool, err error) {
	it, err := mc.Get(sessId)
	if err != nil && err != memcache.ErrCacheMiss {
		// actual error
		log.Warnf("[Auth] Token cache fetch error for '%s': %v", sessId, err)
		return nil, false, err
	}

	if err == memcache.ErrCacheMiss {
		// not found - not an error though
		log.Trace("[Auth] Token cache - miss")
		return nil, false, nil
	}

	if bytes.Equal(it.Value, []byte(invalidPlaceholder)) {
		// cached invalid
		log.Tracef("[Auth] Token cache - invalid placeholder in cache for %s", sessId)
		return nil, true, nil
	}

	u, err = FromSessionToken(sessId, string(it.Value))
	if err != nil {
		// found, but we can't decode - treat as not found
		log.Warnf("[Auth] Token cache decode error: %v", err)
		return nil, false, nil
	}

	return u, true, nil
}
開發者ID:choirudin2210,項目名稱:service-layer,代碼行數:29,代碼來源:cache.go

示例6: Bulk

func (s *ESAPIV0) Bulk(data *bytes.Buffer) {
	if data == nil || data.Len() == 0 {
		return
	}
	data.WriteRune('\n')
	url := fmt.Sprintf("%s/_bulk", s.Host)

	client := &http.Client{}
	reqest, _ := http.NewRequest("POST", url, data)
	if s.Auth != nil {
		reqest.SetBasicAuth(s.Auth.User, s.Auth.Pass)
	}
	resp, errs := client.Do(reqest)
	if errs != nil {
		log.Error(errs)
		return
	}

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Error(err)
		return
	}
	log.Trace(url, string(body))
	defer resp.Body.Close()
	defer data.Reset()
	if resp.StatusCode != 200 {
		log.Errorf("bad bulk response: %s %s", body, resp.StatusCode)
		return
	}
}
開發者ID:medcl,項目名稱:elasticsearch-migration,代碼行數:31,代碼來源:v0.go

示例7: RawMessage

func (ss *Session) RawMessage(msg []byte) error {
	log.Trace("RawMessage ", string(msg))
	packet, err := decodePacket(msg)
	if err != nil {
		log.Info("decodePacket error ", err, string(msg))
		return nil
	}
	if packet == nil {
		log.Info("packet == nil ")
		return nil

	}

	if packet.EndPoint() == "" {
		if err := ss.onPacket(packet); err != nil {
			log.Error(err)
			return nil
		}
	}

	ns := ss.Of(packet.EndPoint())
	if ns == nil {
		return nil
	}
	ns.onPacket(packet)
	return nil
}
開發者ID:xjtdy888,項目名稱:go-socket.io,代碼行數:27,代碼來源:session.go

示例8: Trace

// Trace outputs trace level message.
func Trace(msg ...interface{}) {
	if !isValid {
		return
	}
	mutex.Lock()
	defer mutex.Unlock()
	seelog.Trace(msg...)
}
開發者ID:unirita,項目名稱:gocutoweb,代碼行數:9,代碼來源:log.go

示例9: Trace

// traceレベルでログメッセージを出力する。
//
// param : msg 出力するメッセージ。複數指定した場合は結合して出力される。
func Trace(msg ...interface{}) {
	if !valid {
		return
	}
	locker.Lock(lockTimeout)
	defer locker.Unlock()
	seelog.Trace(msg...)
}
開發者ID:unikk,項目名稱:cuto,代碼行數:11,代碼來源:log.go

示例10: OnRegResp

func (this *Receiver) OnRegResp(arg ArgOnRegResp, reply *ReplyOnRegResp) error {
	log.Trace("RPC: OnRegResp")
	log.Infof("Regist response: RegId: %s, Result: %d", arg.RegId, arg.Result)
	this.RegId = arg.RegId
	if arg.Result != 0 {
		log.Error("Regist failed")
	}
	return nil
}
開發者ID:zhengzhiren,項目名稱:pushserver,代碼行數:9,代碼來源:receiverrpc.go

示例11: NewScroll

func (s *ESAPIV5) NewScroll(indexNames string, scrollTime string, docBufferCount int, query string, slicedId, maxSlicedCount int) (scroll *Scroll, err error) {
	url := fmt.Sprintf("%s/%s/_search?scroll=%s&size=%d", s.Host, indexNames, scrollTime, docBufferCount)

	jsonBody := ""
	if len(query) > 0 || maxSlicedCount > 0 {
		queryBody := map[string]interface{}{}

		if len(query) > 0 {
			queryBody["query"] = map[string]interface{}{}
			queryBody["query"].(map[string]interface{})["query_string"] = map[string]interface{}{}
			queryBody["query"].(map[string]interface{})["query_string"].(map[string]interface{})["query"] = query
		}

		if maxSlicedCount > 1 {
			log.Tracef("sliced scroll, %d of %d", slicedId, maxSlicedCount)
			queryBody["slice"] = map[string]interface{}{}
			queryBody["slice"].(map[string]interface{})["id"] = slicedId
			queryBody["slice"].(map[string]interface{})["max"] = maxSlicedCount
		}

		jsonArray, err := json.Marshal(queryBody)
		if err != nil {
			log.Error(err)

		} else {
			jsonBody = string(jsonArray)
		}
	}

	resp, body, errs := Post(url, s.Auth, jsonBody, s.HttpProxy)

	if errs != nil {
		log.Error(errs)
		return nil, errs[0]
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		return nil, errors.New(body)
	}

	log.Trace("new scroll,", body)

	if err != nil {
		log.Error(err)
		return nil, err
	}

	scroll = &Scroll{}
	err = json.Unmarshal([]byte(body), scroll)
	if err != nil {
		log.Error(err)
		return nil, err
	}

	return scroll, err
}
開發者ID:medcl,項目名稱:elasticsearch-migration,代碼行數:57,代碼來源:v5.go

示例12: OnReceiveMsg

func (this *Receiver) OnReceiveMsg(arg ArgOnReceiveMsg, reply *ReplyOnReceiveMsg) error {
	log.Trace("RPC: OnReceiveMsg")
	log.Infof("Received message. MsgId: %d, MsgType: %d, Msg: %s", arg.MsgId, arg.MsgType, arg.Msg)
	if lastMsgId == 0 {
		lastMsgId = arg.MsgId
	} else if lastMsgId >= arg.MsgId {
		log.Errorf("Received bad message Id: %d, LastMsgId: %d", arg.MsgId, lastMsgId)
	}
	return nil
}
開發者ID:zhengzhiren,項目名稱:pushserver,代碼行數:10,代碼來源:receiverrpc.go

示例13: doTest

func doTest() {
	start := time.Now()
	for i := 0; i < 50; i += 2 {
		fmt.Printf("%d\n", i)
		log.Trace(longMessage)
		log.Debugf("%d", i+1)
	}
	end := time.Now()
	dur := end.Sub(start)
	fmt.Printf("Test took %d ns\n", dur)
}
開發者ID:Krave-n,項目名稱:seelog-examples,代碼行數:11,代碼來源:types_main.go

示例14: defaultFormat

func defaultFormat() {
	fmt.Println("Default format")

	testConfig := `
<seelog type="sync" />`

	logger, err := log.LoggerFromConfigAsBytes([]byte(testConfig))
	if err != nil {
		fmt.Println(err)
	}
	log.ReplaceLogger(logger)

	log.Trace("Test message!")
}
開發者ID:cihub,項目名稱:seelog-examples,代碼行數:14,代碼來源:formats_main.go

示例15: Request

func Request(method string, r string, auth *Auth, body *bytes.Buffer, proxy string) (string, error) {

	var client *http.Client
	client = &http.Client{}
	if len(proxy) > 0 {
		proxyURL, err := url.Parse(proxy)
		if err != nil {
			log.Error(err)
		} else {
			transport := &http.Transport{Proxy: http.ProxyURL(proxyURL)}
			client = &http.Client{Transport: transport}
		}
	}

	var reqest *http.Request
	if body != nil {
		reqest, _ = http.NewRequest(method, r, body)
	} else {
		reqest, _ = newDeleteRequest(client, method, r)
	}
	if auth != nil {
		reqest.SetBasicAuth(auth.User, auth.Pass)
	}

	resp, errs := client.Do(reqest)
	if errs != nil {
		log.Error(errs)
		return "", errs
	}

	if resp.StatusCode != 200 {
		b, _ := ioutil.ReadAll(resp.Body)
		return "", errors.New("server error: " + string(b))
	}

	respBody, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		log.Error(err)
		return string(respBody), err
	}

	log.Trace(r, string(respBody))

	if err != nil {
		return string(respBody), err
	}
	defer resp.Body.Close()
	return string(respBody), nil
}
開發者ID:medcl,項目名稱:elasticsearch-migration,代碼行數:50,代碼來源:http.go


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