fix stack overflow

This commit is contained in:
Pavel 2024-01-19 14:48:18 +03:00
parent 3afa198be2
commit aead3854e1

View File

@ -37,11 +37,11 @@ func NewDefault(debug bool) Logger {
}
func (l *Default) With(fields ...zap.Field) Logger {
return l.With(fields...).(Logger)
return l.clone(l.Logger.With(fields...))
}
func (l *Default) WithLazy(fields ...zap.Field) Logger {
return l.WithLazy(fields...).(Logger)
return l.clone(l.Logger.WithLazy(fields...))
}
func (l *Default) ForHandler(handler any) Logger {
@ -56,6 +56,10 @@ func (l *Default) ForAccount(acc any) Logger {
return l.WithLazy(zap.Any(AccountAttr, acc))
}
func (l *Default) clone(log *zap.Logger) Logger {
return &Default{Logger: log}
}
func AnyZapFields(args []interface{}) []zap.Field {
fields := make([]zap.Field, len(args))
for i := 0; i < len(fields); i++ {