package logger

import (
	"fmt"
	"os"
	"hyperia/config"

	"github.com/rs/zerolog"
	"github.com/rs/zerolog/log"
	"gopkg.in/natefinch/lumberjack.v2"
)

// Very basic setup for starters,
func ConfigureLogger() {
	if !config.LOG_TO_FILE {
		log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
	} else {
		fmt.Println("logging to file /var/log/hyperia-server.log")
		logFile := &lumberjack.Logger{
			Filename:   "/var/log/hyperia-server.log", // Path to your log file
			MaxSize:    100,                        // Max size in MB before rotation
			MaxBackups: 3,                          // Max number of old log files to keep
			MaxAge:     28,                         // Max number of days to retain old log files
			Compress:   true,                       // Whether to compress old log files
		}
		log.Logger = zerolog.New(logFile).With().Timestamp().Logger()
	}
}
