basic app
This commit is contained in:
parent
0a6e246a5c
commit
8d6c2b6687
30 changed files with 1469 additions and 0 deletions
35
internal/logging/logging.go
Normal file
35
internal/logging/logging.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func LogSetup(lvl string) {
|
||||
l, err := log.ParseLevel(lvl)
|
||||
if err != nil {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
||||
log.SetFormatter(
|
||||
&log.TextFormatter{
|
||||
FullTimestamp: true,
|
||||
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
|
||||
filename := path.Base(f.File)
|
||||
return fmt.Sprintf("%s()", f.Function), fmt.Sprintf(" %s:%d", filename, f.Line)
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
if l == log.DebugLevel {
|
||||
log.SetLevel(l)
|
||||
//log.SetReportCaller(true)
|
||||
} else {
|
||||
log.SetLevel(l)
|
||||
}
|
||||
|
||||
log.SetOutput(os.Stdout)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue