@@ -41,7 +41,6 @@ func sync(cmd *cobra.Command, args []string) error {
4141 fmt .Printf ("Loading spec(s) from %s\n " , strings .Join (args , ", " ))
4242 specReader , err := specs .NewSpecReader (args )
4343 if err != nil {
44- log .Error ().Strs ("args" , args ).Err (err ).Msg ("Failed to load spec(s)" )
4544 return fmt .Errorf ("failed to load spec(s) from %s. Error: %w" , strings .Join (args , ", " ), err )
4645 }
4746
@@ -83,6 +82,7 @@ func syncConnection(ctx context.Context, sourceSpec specs.Source, destinationsSp
8382 }
8483 defer func () {
8584 if err := sourceClient .Terminate (); err != nil {
85+ log .Error ().Err (err ).Msg ("Failed to terminate source client" )
8686 fmt .Println ("failed to terminate source client: " , err )
8787 }
8888 }()
@@ -96,6 +96,7 @@ func syncConnection(ctx context.Context, sourceSpec specs.Source, destinationsSp
9696 for _ , destClient := range destClients {
9797 if destClient != nil {
9898 if err := destClient .Terminate (); err != nil {
99+ log .Error ().Err (err ).Msg ("Failed to terminate destination client" )
99100 fmt .Println ("failed to terminate destination client: " , err )
100101 }
101102 }
@@ -123,6 +124,7 @@ func syncConnection(ctx context.Context, sourceSpec specs.Source, destinationsSp
123124
124125 resources := make (chan []byte )
125126 g , gctx := errgroup .WithContext (ctx )
127+ log .Info ().Str ("source" , sourceSpec .Name ).Strs ("destinations" , sourceSpec .Destinations ).Msg ("Start fetching resources" )
126128 fmt .Println ("Starting sync for: " , sourceSpec .Name , "->" , sourceSpec .Destinations )
127129 g .Go (func () error {
128130 defer close (resources )
@@ -149,7 +151,7 @@ func syncConnection(ctx context.Context, sourceSpec specs.Source, destinationsSp
149151 var destFailedWrites uint64
150152 var err error
151153 if destFailedWrites , err = destClients [i ].Write (gctx , sourceSpec .Path , syncTime , destSubscriptions [i ]); err != nil {
152- log . Error (). Err ( err ). Msgf ( "failed to write for %s->%s" , sourceSpec .Name , destination )
154+ return fmt . Errorf ( "failed to write for %s->%s: %w " , sourceSpec .Name , destination , err )
153155 }
154156 failedWrites += destFailedWrites
155157 return nil
@@ -185,5 +187,7 @@ func syncConnection(ctx context.Context, sourceSpec specs.Source, destinationsSp
185187 _ = bar .Finish ()
186188 fmt .Println ("Sync completed successfully." )
187189 fmt .Printf ("Summary: resources: %d, errors: %d, panic: %d failed_writes: %d\n " , totalResources , summary .Errors , summary .Panics , failedWrites )
190+ log .Info ().Str ("source" , sourceSpec .Name ).Strs ("destinations" , sourceSpec .Destinations ).
191+ Int ("resources" , totalResources ).Uint64 ("errors" , summary .Errors ).Uint64 ("panic" , summary .Panics ).Uint64 ("failedWrites" , failedWrites ).Msg ("sync completed successfully" )
188192 return nil
189193}
0 commit comments