tail icon indicating copy to clipboard operation
tail copied to clipboard

Simplify the Logger interface

Open matthewmueller opened this issue 10 months ago • 0 comments

Is your feature request related to a problem? Please describe.

Hey there, thanks for modernizing this library!

Currently the Logger interface looks like this:

type logger interface {
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	Fatalln(v ...interface{})
	Panic(v ...interface{})
	Panicf(format string, v ...interface{})
	Panicln(v ...interface{})
	Print(v ...interface{})
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}

But the library itself only uses Printf. Since this interface isn't compatible with the new *slog.Logger it requires wrapping.

Ideally, we wouldn't have to wrap all these methods, just the ones that the library uses

Describe the solution you'd like A clear and concise description of what you want to happen.

I'd suggest reducing the Logger interface to what's necessary:

type logger interface {
  Printf(format string, v ...interface{})
}

And perhaps any other methods to future-proof it (seems like there's another issue to log errors).

Describe alternatives you've considered Current alternative is to wrap it.

matthewmueller avatar Dec 22 '24 05:12 matthewmueller