package gnet

import (
	"log"
	"os"
)

type Logger interface {
	Error(f string, v ...any)
	Warn(f string, v ...any)
	Info(f string, v ...any)
	Debug(f string, v ...any)
}

type defaultLogger struct {
	lg *log.Logger
}

func (l *defaultLogger) Error(f string, v ...any) {
	l.lg.Printf(f, v...)
}

func (l *defaultLogger) Warn(f string, v ...any) {
	l.lg.Printf(f, v...)
}

func (l *defaultLogger) Info(f string, v ...any) {
	l.lg.Printf(f, v...)
}

func (l *defaultLogger) Debug(f string, v ...any) {
	l.lg.Printf(f, v...)
}

var (
	DefaultLogger = func(prefix string) Logger {
		return &defaultLogger{lg: log.New(os.Stdout, prefix, log.LstdFlags)}
	}
)
