Start adding some logging

This commit is contained in:
Carl Pearson
2024-09-21 06:22:34 -06:00
parent 62d9ebf74b
commit dc04468f7c
6 changed files with 72 additions and 13 deletions

28
logger.go Normal file
View 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)
}