28 lines
469 B
Go
28 lines
469 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.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
|
||
|
}
|