@@ -21,7 +21,6 @@ import (
2121
2222 "github.com/avast/retry-go/v4"
2323 "go.uber.org/multierr"
24- "go.uber.org/zap"
2524)
2625
2726var (
@@ -43,11 +42,11 @@ type bestEffortUnit struct {
4342
4443func (u * bestEffortUnit ) rollbackInserts (ctx context.Context , mCtx UnitMapperContext ) (err error ) {
4544 //delete successfully inserted entities.
46- u .logger .Debug ("attempting to rollback inserted entities" , zap . Int ( "count" , u .successfulInsertCount ) )
45+ u .logger .Debug ("attempting to rollback inserted entities" , "count" , u .successfulInsertCount )
4746 for typeName , i := range u .successfulInserts {
4847 if f , ok := u .deleteFunc (typeName ); ok {
4948 if err = f (ctx , mCtx , i ... ); err != nil {
50- u .logger .Error (err .Error (), zap . String ( "typeName" , typeName .String () ))
49+ u .logger .Error (err .Error (), "typeName" , typeName .String ())
5150 return
5251 }
5352 }
@@ -57,11 +56,11 @@ func (u *bestEffortUnit) rollbackInserts(ctx context.Context, mCtx UnitMapperCon
5756
5857func (u * bestEffortUnit ) rollbackUpdates (ctx context.Context , mCtx UnitMapperContext ) (err error ) {
5958 //reapply previously registered state for the entities.
60- u .logger .Debug ("attempting to rollback updated entities" , zap . Int ( "count" , u .successfulUpdateCount ) )
59+ u .logger .Debug ("attempting to rollback updated entities" , "count" , u .successfulUpdateCount )
6160 for typeName , r := range u .registered {
6261 if f , ok := u .updateFunc (typeName ); ok {
6362 if err = f (ctx , mCtx , r ... ); err != nil {
64- u .logger .Error (err .Error (), zap . String ( "typeName" , typeName .String () ))
63+ u .logger .Error (err .Error (), "typeName" , typeName .String ())
6564 return
6665 }
6766 }
@@ -71,11 +70,11 @@ func (u *bestEffortUnit) rollbackUpdates(ctx context.Context, mCtx UnitMapperCon
7170
7271func (u * bestEffortUnit ) rollbackDeletes (ctx context.Context , mCtx UnitMapperContext ) (err error ) {
7372 //reinsert successfully deleted entities.
74- u .logger .Debug ("attempting to rollback deleted entities" , zap . Int ( "count" , u .successfulDeleteCount ) )
73+ u .logger .Debug ("attempting to rollback deleted entities" , "count" , u .successfulDeleteCount )
7574 for typeName , d := range u .successfulDeletes {
7675 if f , ok := u .insertFunc (typeName ); ok {
7776 if err = f (ctx , mCtx , d ... ); err != nil {
78- u .logger .Error (err .Error (), zap . String ( "typeName" , typeName .String () ))
77+ u .logger .Error (err .Error (), "typeName" , typeName .String ())
7978 return
8079 }
8180 }
@@ -92,7 +91,7 @@ func (u *bestEffortUnit) rollback(ctx context.Context, mCtx UnitMapperContext) (
9291 stop ()
9392 if r := recover (); r != nil {
9493 msg := "panic: unable to rollback work unit"
95- u .logger .Error (msg , zap . String ( "panic" , fmt .Sprintf ("%v" , r ) ))
94+ u .logger .Error (msg , "panic" , fmt .Sprintf ("%v" , r ))
9695 u .scope .Counter (rollbackFailure ).Inc (1 )
9796 panic (r )
9897 }
@@ -128,7 +127,7 @@ func (u *bestEffortUnit) applyInserts(ctx context.Context, mCtx UnitMapperContex
128127 u .executeActions (UnitActionTypeAfterRollback )
129128 }
130129 err = multierr .Combine (err , errRollback )
131- u .logger .Error (err .Error (), zap . String ( "typeName" , typeName .String () ))
130+ u .logger .Error (err .Error (), "typeName" , typeName .String ())
132131 return
133132 }
134133 if _ , ok := u .successfulInserts [typeName ]; ! ok {
@@ -152,7 +151,7 @@ func (u *bestEffortUnit) applyUpdates(ctx context.Context, mCtx UnitMapperContex
152151 u .executeActions (UnitActionTypeAfterRollback )
153152 }
154153 err = multierr .Combine (err , errRollback )
155- u .logger .Error (err .Error (), zap . String ( "typeName" , typeName .String () ))
154+ u .logger .Error (err .Error (), "typeName" , typeName .String ())
156155 return
157156 }
158157 if _ , ok := u .successfulUpdates [typeName ]; ! ok {
@@ -176,7 +175,7 @@ func (u *bestEffortUnit) applyDeletes(ctx context.Context, mCtx UnitMapperContex
176175 u .executeActions (UnitActionTypeAfterRollback )
177176 }
178177 err = multierr .Combine (err , errRollback )
179- u .logger .Error (err .Error (), zap . String ( "typeName" , typeName .String () ))
178+ u .logger .Error (err .Error (), "typeName" , typeName .String ())
180179 return
181180 }
182181 if _ , ok := u .successfulDeletes [typeName ]; ! ok {
@@ -244,8 +243,7 @@ func (u *bestEffortUnit) Save(ctx context.Context) (err error) {
244243 }
245244 err = multierr .Combine (
246245 fmt .Errorf ("panic: unable to save work unit\n %v" , r ), err )
247- u .logger .Error ("panic: unable to save work unit" ,
248- zap .String ("panic" , fmt .Sprintf ("%v" , r )))
246+ u .logger .Error ("panic: unable to save work unit" , "panic" , fmt .Sprintf ("%v" , r ))
249247 panic (r )
250248 }
251249 if err == nil {
@@ -261,11 +259,7 @@ func (u *bestEffortUnit) Save(ctx context.Context) (err error) {
261259 retry .OnRetry (func (attempt uint , err error ) {
262260 u .resetSuccesses ()
263261 u .resetSuccessCounts ()
264- u .logger .Warn (
265- "attempted retry" ,
266- zap .Int ("attempt" , int (attempt + 1 )),
267- zap .Error (err ),
268- )
262+ u .logger .Warn ("attempted retry" , "attempt" , int (attempt + 1 ), "error" , err .Error ())
269263 u .scope .Counter (retryAttempt ).Inc (1 )
270264 })
271265 u .retryOptions = append (u .retryOptions , retry .Context (ctx ), onRetry )
0 commit comments