package main

type Logger interface {
	Printf(format string, v ...any)
	Println(v ...any)
}

type Service struct {
	Name string
	Logger
}

type nopLogger struct{}

func (n nopLogger) Printf(format string, v ...any) {}
func (n nopLogger) Println(v ...any)               {}

func NewService(n string, l Logger) *Service {
	return &Service{
		Name:   n,
		Logger: l,
	}
}

func (s *Service) Init() {
	s.Logger.Printf("initializing : %s\n", s.Name)
}

func (s *Service) Stop() {
	s.Logger.Printf("shutting down: %s\n", s.Name)
}

func main() {
	//l := log.New(os.Stdout, "[service] ", log.Lshortfile)
	s := NewService("example", nopLogger{})
	s.Init()
	s.Stop()
}
