well-goknown/vendor/git.devvul.com/asara/gologger/gologger.go

38 lines
564 B
Go

package gologger
import (
"io"
"os"
"sync"
"time"
"github.com/rs/zerolog"
)
var once sync.Once
var log zerolog.Logger
func Get(l string) zerolog.Logger {
once.Do(func() {
zerolog.TimeFieldFormat = time.RFC3339Nano
var output io.Writer = zerolog.ConsoleWriter{
Out: os.Stdout,
TimeFormat: time.RFC3339,
}
level, err := zerolog.ParseLevel(l)
if err != nil {
panic("unable to get parse level for logger")
}
log = zerolog.New(output).
Level(zerolog.Level(level)).
With().
Timestamp().
Logger()
})
return log
}