package logger

import (
	
	

	
	
	
)

var (
	logger *zap.Logger
)

/*
Init Logger

Creates log file if does not exist and configures Zap logger
*/
func () {
	// TODO: Implement lumberjack log roller
	// https://gist.github.com/rnyrnyrny/a6dc926ae11951b753ecd66c00695397

	 := zap.NewProductionConfig()
	,  := strconv.ParseBool(helpers.Env("APP_DEBUG", "false"))
	if  != nil {
		panic()
	}
	.DisableStacktrace = 
	.OutputPaths = []string{
		"stdout",
		"/liman/logs/liman_new.log",
	}

	logger,  = .Build()
	if  != nil {
		log.Fatalf("can't initialize zap logger: %v", )
	}
}

type Zapper interface {
	Infow(msg string, keysAndValues ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
}

func () *zap.Logger {
	return logger
}

// A Logger provides fast, leveled, structured logging. All methods are safe for concurrent use.
func () *zap.Logger {
	return logger.WithOptions(zap.AddCallerSkip(1))
}

// Sugar wraps the Logger to provide a more ergonomic, but slightly slower, API. Sugaring a Logger is quite inexpensive,
// so it's reasonable for a single application to use both Loggers and SugaredLoggers,
// converting between them on the boundaries of performance-sensitive code.
func () *zap.SugaredLogger {
	return logger.Sugar().WithOptions(zap.AddCallerSkip(1))
}

// This method wraps Zap sugared logger with fiber errors
func ( int,  string) *fiber.Error {
	switch {
	case  >= 500:
		Sugar().Errorw(
			,
			"code", ,
		)
	case  >= 400:
		Sugar().Warnw(
			,
			"code", ,
		)
	default:
		Sugar().Infow(
			,
			"code", ,
		)
	}

	return fiber.NewError(, )
}