diff options
Diffstat (limited to 'matterbridge.go')
-rw-r--r-- | matterbridge.go | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/matterbridge.go b/matterbridge.go index da0df103..24caa5d9 100644 --- a/matterbridge.go +++ b/matterbridge.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "os" + "runtime" "strings" "github.com/42wim/matterbridge/bridge/config" @@ -67,17 +68,31 @@ func setupLogger() *logrus.Logger { Formatter: &prefixed.TextFormatter{ PrefixPadding: 13, DisableColors: true, - FullTimestamp: true, }, Level: logrus.InfoLevel, } if *flagDebug || os.Getenv("DEBUG") == "1" { + logger.SetReportCaller(true) logger.Formatter = &prefixed.TextFormatter{ - PrefixPadding: 13, - DisableColors: true, - FullTimestamp: false, - ForceFormatting: true, + PrefixPadding: 13, + DisableColors: true, + FullTimestamp: false, + + CallerFormatter: func(function, file string) string { + return fmt.Sprintf(" [%s:%s]", function, file) + }, + CallerPrettyfier: func(f *runtime.Frame) (string, string) { + sp := strings.SplitAfter(f.File, "/matterbridge/") + filename := f.File + if len(sp) > 1 { + filename = sp[1] + } + s := strings.Split(f.Function, ".") + funcName := s[len(s)-1] + return funcName, fmt.Sprintf("%s:%d", filename, f.Line) + }, } + logger.Level = logrus.DebugLevel logger.WithFields(logrus.Fields{"prefix": "main"}).Info("Enabling debug logging.") } |