package mlogger

import (
	"github.com/tech/sendico/pkg/mlogger"
	"github.com/mattn/go-colorable"
	"go.uber.org/zap"
	"go.uber.org/zap/zapcore"
)

func NewLoggerImp(debug bool) mlogger.Logger {
	if debug {
		dc := zap.NewDevelopmentEncoderConfig()
		dc.EncodeLevel = zapcore.CapitalColorLevelEncoder
		logger := zap.New(zapcore.NewCore(
			zapcore.NewConsoleEncoder(dc),
			zapcore.AddSync(colorable.NewColorableStdout()),
			zapcore.DebugLevel,
		))
		return logger
	}

	return zap.Must(zap.NewProduction())
}
