@@ -78,7 +78,7 @@ func (c *Client) DoMultiPartRequest(method, endpoint string, files map[string][]
78
78
79
79
if c .config .CustomTimeout > 0 {
80
80
ctx , cancel = context .WithTimeout (context .Background (), c .config .CustomTimeout )
81
- c .Sugar .Info ("Using timeout context for multipart request" , zap .Duration ("custom_timeout_seconds" , c .config .CustomTimeout ))
81
+ c .Sugar .Infow ("Using timeout context for multipart request" , zap .Duration ("custom_timeout_seconds" , c .config .CustomTimeout ))
82
82
} else {
83
83
ctx = context .Background ()
84
84
cancel = func () {}
@@ -94,25 +94,25 @@ func (c *Client) DoMultiPartRequest(method, endpoint string, files map[string][]
94
94
var err error
95
95
body , contentType , err = createStreamingMultipartRequestBody (files , formDataFields , fileContentTypes , formDataPartHeaders , c .Sugar )
96
96
if err != nil {
97
- c .Sugar .Error ("Failed to create streaming multipart request body" , zap .Error (err ))
97
+ c .Sugar .Errorw ("Failed to create streaming multipart request body" , zap .Error (err ))
98
98
} else {
99
- c .Sugar .Info ("Successfully created streaming multipart request body" , zap .String ("content_type" , contentType ))
99
+ c .Sugar .Infow ("Successfully created streaming multipart request body" , zap .String ("content_type" , contentType ))
100
100
}
101
101
return err
102
102
}
103
103
104
104
if err := createBody (); err != nil {
105
- c .Sugar .Error ("Failed to create streaming multipart request body" , zap .Error (err ))
105
+ c .Sugar .Errorw ("Failed to create streaming multipart request body" , zap .Error (err ))
106
106
return nil , err
107
107
}
108
108
109
109
req , err := http .NewRequestWithContext (ctx , method , url , body )
110
110
if err != nil {
111
- c .Sugar .Error ("Failed to create HTTP request" , zap .Error (err ))
111
+ c .Sugar .Errorw ("Failed to create HTTP request" , zap .Error (err ))
112
112
return nil , err
113
113
}
114
114
115
- c .Sugar .Info ("Created HTTP Multipart request" , zap .String ("method" , method ), zap .String ("url" , url ), zap .String ("content_type" , contentType ))
115
+ c .Sugar .Infow ("Created HTTP Multipart request" , zap .String ("method" , method ), zap .String ("url" , url ), zap .String ("content_type" , contentType ))
116
116
117
117
(* c .Integration ).PrepRequestParamsAndAuth (req )
118
118
@@ -124,11 +124,11 @@ func (c *Client) DoMultiPartRequest(method, endpoint string, files map[string][]
124
124
duration := time .Since (startTime )
125
125
126
126
if requestErr != nil {
127
- c .Sugar .Error ("Failed to send request" , zap .String ("method" , method ), zap .String ("endpoint" , endpoint ), zap .Error (requestErr ))
127
+ c .Sugar .Errorw ("Failed to send request" , zap .String ("method" , method ), zap .String ("endpoint" , endpoint ), zap .Error (requestErr ))
128
128
return nil , requestErr
129
129
}
130
130
131
- c .Sugar .Debug ("Request sent successfully" , zap .String ("method" , method ), zap .String ("endpoint" , endpoint ), zap .Int ("status_code" , resp .StatusCode ), zap .Duration ("duration" , duration ))
131
+ c .Sugar .Debugw ("Request sent successfully" , zap .String ("method" , method ), zap .String ("endpoint" , endpoint ), zap .Int ("status_code" , resp .StatusCode ), zap .Duration ("duration" , duration ))
132
132
133
133
if resp .StatusCode >= 200 && resp .StatusCode < 300 {
134
134
return resp , response .HandleAPISuccessResponse (resp , out , c .Sugar )
@@ -268,11 +268,11 @@ func addFilePart(writer *multipart.Writer, fieldName, filePath string, fileConte
268
268
func addFormField (writer * multipart.Writer , key , val string , sugar * zap.SugaredLogger ) error {
269
269
fieldWriter , err := writer .CreateFormField (key )
270
270
if err != nil {
271
- sugar .Error ("Failed to create form field" , zap .String ("key" , key ), zap .Error (err ))
271
+ sugar .Errorw ("Failed to create form field" , zap .String ("key" , key ), zap .Error (err ))
272
272
return err
273
273
}
274
274
if _ , err := fieldWriter .Write ([]byte (val )); err != nil {
275
- sugar .Error ("Failed to write form field" , zap .String ("key" , key ), zap .Error (err ))
275
+ sugar .Errorw ("Failed to write form field" , zap .String ("key" , key ), zap .Error (err ))
276
276
return err
277
277
}
278
278
return nil
@@ -363,7 +363,7 @@ func chunkFileUpload(file *os.File, writer io.Writer, updateProgress func(int64)
363
363
364
364
if chunkWritten >= chunkSize {
365
365
currentChunk ++
366
- sugar .Debug ("File Upload Chunk Sent" ,
366
+ sugar .Debugw ("File Upload Chunk Sent" ,
367
367
zap .String ("file_name" , fileName ),
368
368
zap .Int64 ("chunk_number" , currentChunk ),
369
369
zap .Int64 ("total_chunks" , totalChunks ),
@@ -376,7 +376,7 @@ func chunkFileUpload(file *os.File, writer io.Writer, updateProgress func(int64)
376
376
// sugar any remaining bytes that were written but didn't reach the sugar threshold
377
377
if chunkWritten > 0 {
378
378
currentChunk ++
379
- sugar .Debug ("Final Upload Chunk Sent" ,
379
+ sugar .Debugw ("Final Upload Chunk Sent" ,
380
380
zap .String ("file_name" , fileName ),
381
381
zap .Int64 ("chunk_number" , currentChunk ),
382
382
zap .Int64 ("total_chunks" , totalChunks ),
@@ -412,7 +412,7 @@ func logUploadProgress(file *os.File, fileSize int64, sugar *zap.SugaredLogger)
412
412
if percentage >= lastLoggedPercentage + logInterval {
413
413
elapsedTime := time .Since (startTime )
414
414
415
- sugar .Info ("Upload progress" ,
415
+ sugar .Infow ("Upload progress" ,
416
416
zap .String ("file_name" , fileName ),
417
417
zap .Float64 ("uploaded_MB's" , float64 (uploaded )/ 1048576 ), // sugar in MB (1024 * 1024)
418
418
zap .Float64 ("total_filesize_in_MB" , float64 (fileSize )/ 1048576 ),
0 commit comments