本文整理汇总了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
}
示例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
}
示例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!")
}
示例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")
}
示例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
}
示例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
}
}
示例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
}
示例8: Trace
// Trace outputs trace level message.
func Trace(msg ...interface{}) {
if !isValid {
return
}
mutex.Lock()
defer mutex.Unlock()
seelog.Trace(msg...)
}
示例9: Trace
// traceレベルでログメッセージを出力する。
//
// param : msg 出力するメッセージ。複数指定した場合は結合して出力される。
func Trace(msg ...interface{}) {
if !valid {
return
}
locker.Lock(lockTimeout)
defer locker.Unlock()
seelog.Trace(msg...)
}
示例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
}
示例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
}
示例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
}
示例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)
}
示例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!")
}
示例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
}