apex / apex/log

Question: Not printing line number on error

未关闭
#48 1 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Go
星标
1.4k
派生
110
PR 合并指标
30 天内没有已合并 PR

描述

Hi I ran the tracing sample but it was not printing the line number. This is my current output.

```sh
INFO[0001] opening app=myapp env=prod path=Readme.md
ERROR[0001] opening app=myapp duration=22.987µs env=prod error=open Readme.md: no such file or directory path=Readme.md
INFO[0002] opening app=myapp env=prod path=Readme.md
ERROR[0002] opening app=myapp duration=8.866µs env=prod error=open Readme.md: no such file or directory path=Readme.md
```

My code is (taken from the tracing examlple)
```go
package main

import (
"os"
"time"

"github.com/apex/log"
"github.com/apex/log/handlers/text"
)

func work(ctx log.Interface) (err error) {
path := "Readme.md"
defer ctx.WithField("path", path).Trace("opening").Stop(&err)
_, err = os.Open(path)
return
}

func main() {
log.SetHandler(text.New(os.Stderr))

ctx := log.WithFields(log.Fields{
"app": "myapp",
"env": "prod",
})

for range time.Tick(time.Second) {
_ = work(ctx)
}
}

```

go version go1.8.3 darwin/amd64

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。