Start adding some logging
This commit is contained in:
28
logger.go
Normal file
28
logger.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var log *logrus.Logger
|
||||
|
||||
func initLogger() {
|
||||
|
||||
log = logrus.New()
|
||||
log.SetOutput(os.Stdout)
|
||||
log.SetLevel(logrus.DebugLevel)
|
||||
log.SetFormatter(&logrus.TextFormatter{
|
||||
FullTimestamp: true,
|
||||
TimestampFormat: "2006-01-02 15:04:05",
|
||||
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
|
||||
filename := path.Base(f.File)
|
||||
return "", fmt.Sprintf("%s:%d", filename, f.Line)
|
||||
},
|
||||
})
|
||||
log.SetReportCaller(true)
|
||||
}
|
Reference in New Issue
Block a user