Created
August 1, 2019 17:36
-
-
Save damekr/bdfcc6820b6c7a95aeef63af9bfc3d53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"runtime" | |
"strings" | |
"github.com/sirupsen/logrus" | |
) | |
func main() { | |
log := logrus.New() | |
log.SetReportCaller(true) | |
log.Formatter = &logrus.TextFormatter{ | |
CallerPrettyfier: func(f *runtime.Frame) (string, string) { | |
repopath := fmt.Sprintf("%s/src/github.com/bob", os.Getenv("GOPATH")) | |
filename := strings.Replace(f.File, repopath, "", -1) | |
return fmt.Sprintf("%s()", f.Function), fmt.Sprintf("%s:%d", filename, f.Line) | |
}, | |
} | |
log.Println("hello world") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment