sshpoke/internal/logger/logger.go

29 lines
536 B
Go

package logger
import (
"github.com/Neur0toxine/sshpoke/internal/config"
"go.uber.org/zap"
)
var (
Default *zap.Logger
Sugar *zap.SugaredLogger
)
func Initialize() {
Default = New(config.Default.Debug)
Sugar = Default.Sugar()
}
func New(debug bool) *zap.Logger {
zapConfig := zap.NewProductionConfig()
if debug {
zapConfig = zap.NewDevelopmentConfig()
}
zapConfig.Encoding = "console"
zapConfig.EncoderConfig.CallerKey = ""
zapConfig.EncoderConfig.EncodeCaller = nil
logger, _ := zapConfig.Build()
return logger
}