Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is that can work???? #2

Closed
hellojukay opened this issue Nov 2, 2017 · 4 comments
Closed

is that can work???? #2

hellojukay opened this issue Nov 2, 2017 · 4 comments

Comments

@hellojukay
Copy link

package main
import (
"github.com/onrik/logrus/filename"
"github.com/onrik/logrus/sentry"
log "github.com/sirupsen/logrus"
)

var (
dsn = "http://60a0257d7b5a429a8838e5f2ba873ec9:cb785a64cd3649ea987a1f2f5fad5e82@example.com/1"
)

func main() {
filenameHook := filename.NewHook()
filenameHook.Field = "filename" // Customize source field name
log.AddHook(filenameHook)

sentryHook := sentry.NewHook(dsn, log.PanicLevel, log.FatalLevel, log.ErrorLevel)
log.AddHook(sentryHook)

log.WithFields(log.Fields{
"a":"a",
}).Info("Request info")

}

that is the log ouput:

time="2017-11-03T00:01:49+08:00" level=info msg="Request info" a=a filename="runtime/proc.go:185"

as you can see ,th filename is error!

@onrik
Copy link
Owner

onrik commented Nov 2, 2017

Hmm, it's interesting. I'll check it.

@onrik
Copy link
Owner

onrik commented Nov 2, 2017

Looks like that default skip param is too high for your case. Try to decrease it.

@renathoaz
Copy link

@onrik why doesn't logrus have a default way to log filename and line? I could only achieve it with your hook.

@onrik
Copy link
Owner

onrik commented Nov 21, 2017

@RenathoAzevedo, this issue still open 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants