automemlimit icon indicating copy to clipboard operation
automemlimit copied to clipboard

Make logger configurable as a stdlib compatible interface

Open SuperQ opened this issue 1 year ago • 1 comments

Proposal

In order to support different logging libraries, it would be nice to have logging be an interface to something compatible with the current stdlib log package.

For example:

import "log"

type Logger interface {
	Fatalf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Warnf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Debugf(format string, v ...interface{})
}

SuperQ avatar Jan 13 '24 21:01 SuperQ

Thank you for your proposal.

As I commented in another issue, for now, I'm still likely to use log/slog. But it is still open to change, so feel free to leave any idea about it.

But I need to figure out the interface-type logger. I think just the log/slog package would satisfy almost every case since there are already a lot of ecosystems built on top of log/slog.Handler for adapting third-party loggers. IMHO, only log/slog could be a logger that everyone agrees on like gofmt.

https://github.com/KimMachineGun/automemlimit/issues/5#issuecomment-1892329832

KimMachineGun avatar Jan 15 '24 15:01 KimMachineGun

As I commented, v0.6.0 has been released with log/slog. This issue is closed, but feel free to reopen it if you need further discussion about it.

KimMachineGun avatar Apr 16 '24 13:04 KimMachineGun