Skip to content

Instantly share code, notes, and snippets.

@damekr
Created August 1, 2019 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damekr/bdfcc6820b6c7a95aeef63af9bfc3d53 to your computer and use it in GitHub Desktop.
Save damekr/bdfcc6820b6c7a95aeef63af9bfc3d53 to your computer and use it in GitHub Desktop.
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