@@ -171,6 +171,10 @@ func (s *submitServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
171171 return
172172 }
173173
174+ log .UpdateContext (func (c zerolog.Context ) zerolog.Context {
175+ return c .Str ("verified_user_id" , p .VerifiedUserID ).Str ("verified_device_id" , p .VerifiedDeviceID )
176+ })
177+
174178 if req .Context ().Err () != nil {
175179 return
176180 }
@@ -665,7 +669,7 @@ func (s *submitServer) saveReportBackground(ctx context.Context, p parsedPayload
665669 return err
666670 }
667671
668- if err := s .submitWebhook (context . Background () , p , listingURL , & resp ); err != nil {
672+ if err := s .submitWebhook (ctx , p , listingURL , & resp ); err != nil {
669673 return err
670674 }
671675
@@ -675,14 +679,14 @@ func (s *submitServer) saveReportBackground(ctx context.Context, p parsedPayload
675679func (s * submitServer ) saveReport (log zerolog.Logger , p parsedPayload , reportDir , listingURL string ) error {
676680 var summaryBuf bytes.Buffer
677681 p .WriteToBuffer (& summaryBuf )
678- if err := uploadToS3 (context .Background (), s .s3Client , s .s3Bucket , reportDir , "details.log" , & summaryBuf , true ); err != nil {
682+ ctx := log .WithContext (context .Background ())
683+ if err := uploadToS3 (ctx , s .s3Client , s .s3Bucket , reportDir , "details.log" , & summaryBuf , true ); err != nil {
679684 log .Err (err ).Msg ("Error uploading report details" )
680685 return err
681686 }
682687
683688 go func () {
684- log = log .With ().Str ("action" , "save_report_background" ).Logger ()
685- err := s .saveReportBackground (log .WithContext (context .Background ()), p , listingURL )
689+ err := s .saveReportBackground (ctx , p , listingURL )
686690 if err != nil {
687691 log .Err (err ).Msg ("Error submitting report in background" )
688692 }
@@ -870,7 +874,7 @@ func (s *submitServer) submitWebhook(ctx context.Context, p parsedPayload, listi
870874 if err != nil {
871875 log .Err (err ).Msg ("Error sending webhook request" )
872876 } else if resp .StatusCode < 200 || resp .StatusCode > 300 {
873- log .Printf ( "unexpected webhook HTTP status code %d " , resp .StatusCode )
877+ log .Warn (). Int ( "status_code " , resp .StatusCode ). Msg ( "Unexpected webhook response status" )
874878 } else {
875879 return nil
876880 }
@@ -1111,11 +1115,10 @@ func uploadToS3(ctx context.Context, s3Client *minio.Client, bucket, prefix, nam
11111115 Str ("name" , name ).
11121116 Bool ("compress" , compress ).
11131117 Logger ()
1114- log .Info ().Msg ("Uploading to S3" )
11151118 objectName := prefix + "/" + name
11161119 r := reader // make a copy of reader so that the goroutine can copy from the original
11171120 if compress {
1118- log .Debug ( ).Msg ("Compressing data before upload" )
1121+ log .Trace (). Str ( "object_name" , objectName ).Msg ("Compressing data before upload" )
11191122 pr , pw := io .Pipe ()
11201123 go func () {
11211124 gz := gzip .NewWriter (pw )
@@ -1126,13 +1129,13 @@ func uploadToS3(ctx context.Context, s3Client *minio.Client, bucket, prefix, nam
11261129 r = pr
11271130 objectName += ".gz"
11281131 }
1129- log .Debug ().Str ("object_name" , objectName ).Msg ("Uploading object to S3" )
1132+ log .Trace ().Str ("object_name" , objectName ).Msg ("Uploading object to S3" )
11301133 _ , err := s3Client .PutObject (ctx , bucket , objectName , r , - 1 , minio.PutObjectOptions {
11311134 PartSize : 5 * 1024 * 1024 , // 5MB part size so that our memory usage doesn't balloon
11321135 })
11331136 if err != nil {
11341137 return fmt .Errorf ("failed to upload to S3: %w" , err )
11351138 }
1136- log .Info ( ).Msg ("Successfully uploaded to S3" )
1139+ log .Debug (). Str ( "object_name" , objectName ).Msg ("Successfully uploaded to S3" )
11371140 return nil
11381141}
0 commit comments