func zapSugaredLoggerTo(destWriter io.Writer, development bool) *zap.SugaredLogger {
	sink := zapcore.AddSync(destWriter)
	var enc zapcore.Encoder
	var lvl zap.AtomicLevel
	var opts []zap.Option
	if development {
		encCfg := zap.NewDevelopmentEncoderConfig()
		encCfg.EncodeTime = timeEncoder
		enc = zapcore.NewConsoleEncoder(encCfg)
		lvl = zap.NewAtomicLevelAt(zap.DebugLevel)
		opts = append(opts, zap.Development(), zap.AddStacktrace(zap.ErrorLevel))
	} else {
		encCfg := zap.NewProductionEncoderConfig()
		encCfg.EncodeTime = timeEncoder
		enc = zapcore.NewJSONEncoder(encCfg)
		lvl = zap.NewAtomicLevelAt(zap.InfoLevel)
		opts = append(opts, zap.WrapCore(func(core zapcore.Core) zapcore.Core {
			return zapcore.NewSampler(core, time.Second, 100, 100)
		}))
	}
	opts = append(opts, zap.AddCallerSkip(1), zap.ErrorOutput(sink))
	log := zap.New(zapcore.NewCore(&logzap.KubeAwareEncoder{Encoder: enc, Verbose: development}, sink, lvl))
	log = log.WithOptions(opts...)
	return log.Sugar()
}
zapSugaredLoggerTo returns a new Logger implementation using Zap which logs
to the given destination, instead of stderr.  It otherise behaves like
ZapLogger.
package logs
import (
	"io"
	corev1 "k8s.io/api/core/v1"
	"os"
	"strconv"
	"time"
	"github.com/go-logr/logr"
	"go.uber.org/zap"
	"go.uber.org/zap/zapcore"
	logf "sigs.k8s.io/controller-runtime/pkg/log"
	logzap "sigs.k8s.io/controller-runtime/pkg/log/zap"
)
type Logger struct {
	Logger        logr.Logger
	SugaredLogger *zap.SugaredLogger
}
var DebugTrue = corev1.EnvVar{
	Name:  "DEBUG",
	Value: "true",
}
func GetLogger(name string) *zap.SugaredLogger {
	debugBool := GetBoolEnv(DebugTrue.Name)  
	var logger Logger
	if debugBool {
		logger = createLogger(true)
	} else {
		logger = createLogger(false)
	}
	logger.Logger = logf.Log.WithName(name)
	return logger.SugaredLogger.Named(name)
}
func createLogger(development bool) (logger Logger) {
	log := Logger{
		Logger: logzap.New(func(o *logzap.Options) {
			o.Development = development
		}),
		SugaredLogger: zapSugaredLogger(development),
	}
	defer log.SugaredLogger.Sync()
	logf.SetLogger(log.Logger)
	return log
}
func zapSugaredLogger(development bool) *zap.SugaredLogger {
	return zapSugaredLoggerTo(os.Stderr, development)
}