package logger

import (
	"go.uber.org/zap"
	"log"
)

func New(env string) *zap.SugaredLogger {
	var zapLogger *zap.Logger
	var err error

	if env == "production" {
		zapLogger, err = zap.NewProduction()
	} else {
		zapLogger, err = zap.NewDevelopment()
	}

	if err != nil {
		log.Fatalf("failed to initialize zap logger: %v", err)
	}

	return zapLogger.Sugar()
}

type GooseLogger struct {
	*zap.SugaredLogger
}

func (l *GooseLogger) Fatal(v ...interface{}) {
	l.SugaredLogger.Fatal(v...)
}

func (l *GooseLogger) Fatalf(format string, v ...interface{}) {
	l.SugaredLogger.Fatalf(format, v...)
}

func (l *GooseLogger) Print(v ...interface{}) {
	l.SugaredLogger.Info(v...)
}

func (l *GooseLogger) Printf(format string, v ...interface{}) {
	l.SugaredLogger.Infof(format, v...)
}
