From aead3854e1dfe7b94e0751538dbac692b69d465c Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Fri, 19 Jan 2024 14:48:18 +0300 Subject: [PATCH] fix stack overflow --- core/logger/default.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/logger/default.go b/core/logger/default.go index 62f866d..b79f104 100644 --- a/core/logger/default.go +++ b/core/logger/default.go @@ -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++ {