mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
remove Inner method from Logger interface
This commit is contained in:
parent
77b6db7b45
commit
6ba58e97a9
3 changed files with 3 additions and 15 deletions
|
|
@ -98,10 +98,6 @@ func LoggerWithHandler(t *testing.T, handler slog.Handler) log.Logger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Inner() *slog.Logger {
|
|
||||||
return l.l.Inner()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *logger) Write(level slog.Level, msg string, ctx ...interface{}) {}
|
func (l *logger) Write(level slog.Level, msg string, ctx ...interface{}) {}
|
||||||
|
|
||||||
func (l *logger) Trace(msg string, ctx ...interface{}) {
|
func (l *logger) Trace(msg string, ctx ...interface{}) {
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,6 @@ func LevelString(l slog.Level) string {
|
||||||
|
|
||||||
// A Logger writes key/value pairs to a Handler
|
// A Logger writes key/value pairs to a Handler
|
||||||
type Logger interface {
|
type Logger interface {
|
||||||
// TODO: add WithGroup()?
|
|
||||||
|
|
||||||
// With returns a new Logger that has this logger's attributes plus the given attributes
|
// With returns a new Logger that has this logger's attributes plus the given attributes
|
||||||
With(ctx ...interface{}) Logger
|
With(ctx ...interface{}) Logger
|
||||||
|
|
||||||
|
|
@ -134,9 +132,6 @@ type Logger interface {
|
||||||
// Crit logs a message at the crit level with context key/value pairs, and exits
|
// Crit logs a message at the crit level with context key/value pairs, and exits
|
||||||
Crit(msg string, ctx ...interface{})
|
Crit(msg string, ctx ...interface{})
|
||||||
|
|
||||||
// Inner returns the underlying slog logger that is wrapped
|
|
||||||
Inner() *slog.Logger
|
|
||||||
|
|
||||||
// Write logs a message at the specified level
|
// Write logs a message at the specified level
|
||||||
Write(level slog.Level, msg string, attrs ...any)
|
Write(level slog.Level, msg string, attrs ...any)
|
||||||
}
|
}
|
||||||
|
|
@ -152,11 +147,6 @@ func NewLogger(h slog.Handler) Logger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inner returns the underlying slog logger that
|
|
||||||
func (l *logger) Inner() *slog.Logger {
|
|
||||||
return l.inner
|
|
||||||
}
|
|
||||||
|
|
||||||
// write logs a message at the specified level:
|
// write logs a message at the specified level:
|
||||||
func (l *logger) Write(level slog.Level, msg string, attrs ...any) {
|
func (l *logger) Write(level slog.Level, msg string, attrs ...any) {
|
||||||
if !l.inner.Enabled(context.Background(), level) {
|
if !l.inner.Enabled(context.Background(), level) {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,9 @@ func init() {
|
||||||
// SetDefault sets the default global logger
|
// SetDefault sets the default global logger
|
||||||
func SetDefault(l Logger) {
|
func SetDefault(l Logger) {
|
||||||
root.Store(l)
|
root.Store(l)
|
||||||
slog.SetDefault(l.Inner())
|
if lg, ok := l.(*logger); ok {
|
||||||
|
slog.SetDefault(lg.inner)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Root returns the root logger
|
// Root returns the root logger
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue