sshpoke/internal/logger/logger.go

28 lines
469 B
Go
Raw Normal View History

2023-11-16 20:09:40 +03:00
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.DefaultConfig.Debug)
Sugar = Default.Sugar()
}
func New(debug bool) *zap.Logger {
if debug {
logger, _ := zap.NewDevelopment()
return logger
}
zapConfig := zap.NewProductionConfig()
zapConfig.Encoding = "console"
logger, _ := zapConfig.Build()
return logger
}