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

[log] Fatalf and Panicf log source is incorrect due to calling Fatal and Panic #48

Closed
at15 opened this issue Feb 19, 2018 · 0 comments
Closed
Assignees

Comments

@at15
Copy link
Member

at15 commented Feb 19, 2018

When handling source, we hard coded to go up to level, which is the caller, but when using Fatalf, it does not call HandleLogWithSource directly, thus the source become logger.go:88 ...

func (l *Logger) Fatal(args ...interface{}) {
	s := fmt.Sprint(args...)
	if !l.source {
		l.h.HandleLog(FatalLevel, time.Now(), s)
	} else {
		l.h.HandleLogWithSource(FatalLevel, time.Now(), s, caller())
	}
	l.h.Flush()
	// TODO: allow user to register hook to do cleanup before exit directly
	os.Exit(1)
}

// FIXME: source line is in correct because we call Fatal in Fatalf
func (l *Logger) Fatalf(format string, args ...interface{}) {
	l.Fatal(fmt.Sprintf(format, args...))
}
@at15 at15 self-assigned this Feb 19, 2018
@at15 at15 closed this as completed in 03f9d2a Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant