当前位置: 首页>>代码示例>>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;未经允许,请勿转载。