@@ -517,7 +517,7 @@ func (dbclient *couchDatabase) dropDatabase() (*dbOperationResponse, error) {
517517func (dbclient * couchDatabase ) saveDoc (id string , rev string , couchDoc * couchDoc ) (string , error ) {
518518 dbName := dbclient .dbName
519519
520- couchdbLogger .Debugf ("[%s] Entering SaveDoc() id=[%s]" , dbName , id )
520+ couchdbLogger .Debugf ("[%s] Entering SaveDoc() id=[%s] couchDoc: %+v " , dbName , id , couchDoc )
521521
522522 if ! utf8 .ValidString (id ) {
523523 return "" , errors .Errorf ("doc id [%x] not a valid utf8 string" , id )
@@ -540,16 +540,17 @@ func (dbclient *couchDatabase) saveDoc(id string, rev string, couchDoc *couchDoc
540540
541541 //check to see if attachments is nil, if so, then this is a JSON only
542542 if couchDoc .attachments == nil {
543-
543+ logger . Debugf ( "saveDoc() id: %s couchDoc.attachments == nil" , id )
544544 //Test to see if this is a valid JSON
545545 if ! isJSON (string (couchDoc .jsonValue )) {
546546 return "" , errors .New ("JSON format is not valid" )
547547 }
548548
549549 // if there are no attachments, then use the bytes passed in as the JSON
550550 data = couchDoc .jsonValue
551-
551+ logger . Debugf ( "saveDoc() data: %+v" , data )
552552 } else { // there are attachments
553+ logger .Debugf ("saveDoc() id: %s couchDoc.attachments != nil" , id )
553554
554555 //attachments are included, create the multipart definition
555556 multipartData , multipartBoundary , err3 := createAttachmentPart (couchDoc )
@@ -566,15 +567,15 @@ func (dbclient *couchDatabase) saveDoc(id string, rev string, couchDoc *couchDoc
566567
567568 //Set the data buffer to the data from the create multi-part data
568569 data = multipartData .Bytes ()
569-
570+ logger . Debugf ( "saveDoc() data: %+v" , data )
570571 //Set the default boundary to the value generated in the multipart creation
571572 defaultBoundary = multipartBoundary
572573
573574 }
574575
575576 //get the number of retries
576577 maxRetries := dbclient .couchInstance .conf .MaxRetries
577-
578+ //couchdbLogger.Debugf("[SaveDoc() id:[%s] rev=[%s]",id, rev)
578579 //handle the request for saving document with a retry if there is a revision conflict
579580 resp , _ , err := dbclient .handleRequestWithRevisionRetry (id , http .MethodPut , dbName , "SaveDoc" , saveURL , data , rev , defaultBoundary , maxRetries , keepConnectionOpen , nil )
580581
@@ -589,8 +590,8 @@ func (dbclient *couchDatabase) saveDoc(id string, rev string, couchDoc *couchDoc
589590 return "" , err
590591 }
591592
592- couchdbLogger .Debugf ("[%s] Exiting SaveDoc()" , dbclient . dbName )
593-
593+ // couchdbLogger.Debugf("SaveDoc() %+v",revision )
594+ couchdbLogger . Debugf ( "Database Name : [%s] Revision: [%s] Exiting saveDoc()" , dbclient . dbName , revision )
594595 return revision , nil
595596
596597}
@@ -599,13 +600,14 @@ func (dbclient *couchDatabase) saveDoc(id string, rev string, couchDoc *couchDoc
599600func (dbclient * couchDatabase ) getDocumentRevision (id string ) string {
600601
601602 var rev = ""
602-
603+ logger . Debugf ( "getDocumentRevision" )
603604 //See if the document already exists, we need the rev for saves and deletes
604605 _ , revdoc , err := dbclient .readDoc (id )
605606 if err == nil {
606607 //set the revision to the rev returned from the document read
607608 rev = revdoc
608609 }
610+ logger .Debugf ("getDocumentRevision rev: %v" , rev )
609611 return rev
610612}
611613
@@ -825,7 +827,7 @@ func (dbclient *couchDatabase) readDoc(id string) (*couchDoc, string, error) {
825827 } // for all multiparts
826828
827829 couchDoc .attachments = attachments
828-
830+ couchdbLogger . Debugf ( "return readDoc couchDoc: %+v, revision: %s, nil" , couchDoc , revision )
829831 return & couchDoc , revision , nil
830832 }
831833
@@ -835,7 +837,7 @@ func (dbclient *couchDatabase) readDoc(id string) (*couchDoc, string, error) {
835837 return nil , "" , errors .Wrap (err , "error reading response body" )
836838 }
837839
838- couchdbLogger .Debugf ("[%s] Exiting ReadDoc()" , dbclient .dbName )
840+ couchdbLogger .Debugf ("[%s] Exiting ReadDoc() id: %v revision: %v " , dbclient .dbName , id , revision )
839841 return & couchDoc , revision , nil
840842}
841843
@@ -1456,11 +1458,12 @@ func (dbclient *couchDatabase) batchRetrieveDocumentMetadata(keys []string) ([]*
14561458 if err2 != nil {
14571459 return nil , errors .Wrap (err2 , "error unmarshalling json data" )
14581460 }
1459-
1461+ couchdbLogger . Debugf ( "BatchRetrieveDocumentMetadata() jsonResponse:%+v" , jsonResponse )
14601462 docMetadataArray := []* docMetadata {}
14611463
14621464 for _ , row := range jsonResponse .Rows {
14631465 docMetadata := & docMetadata {ID : row .ID , Rev : row .DocMetadata .Rev , Version : row .DocMetadata .Version }
1466+ couchdbLogger .Debugf ("BatchRetrieveDocumentMetadata() docMetadata:%+v" , docMetadata )
14641467 docMetadataArray = append (docMetadataArray , docMetadata )
14651468 }
14661469
@@ -1473,7 +1476,7 @@ func (dbclient *couchDatabase) batchRetrieveDocumentMetadata(keys []string) ([]*
14731476//batchUpdateDocuments - batch method to batch update documents
14741477func (dbclient * couchDatabase ) batchUpdateDocuments (documents []* couchDoc ) ([]* batchUpdateResponse , error ) {
14751478 dbName := dbclient .dbName
1476-
1479+ logger . Debugf ( "batchUpdateDocuments =[%v]" , documents )
14771480 if couchdbLogger .IsEnabledFor (zapcore .DebugLevel ) {
14781481 documentIdsString , err := printDocumentIds (documents )
14791482 if err == nil {
@@ -1494,7 +1497,7 @@ func (dbclient *couchDatabase) batchUpdateDocuments(documents []*couchDoc) ([]*b
14941497 var jsonDocumentMap []interface {}
14951498
14961499 for _ , jsonDocument := range documents {
1497-
1500+ couchdbLogger . Debugf ( "BatchUpdateDocuments() jsonDocument=[%+v]" , jsonDocument )
14981501 //create a document map
14991502 var document = make (map [string ]interface {})
15001503
@@ -1503,9 +1506,10 @@ func (dbclient *couchDatabase) batchUpdateDocuments(documents []*couchDoc) ([]*b
15031506 if err != nil {
15041507 return nil , errors .Wrap (err , "error unmarshalling json data" )
15051508 }
1506-
1509+ couchdbLogger . Debugf ( "BatchUpdateDocuments() Unmarshal document: %+v" , document )
15071510 //iterate through any attachments
15081511 if len (jsonDocument .attachments ) > 0 {
1512+ couchdbLogger .Debugf ("BatchUpdateDocuments() len(jsonDocument.attachments) > 0" )
15091513
15101514 //create a file attachment map
15111515 fileAttachment := make (map [string ]interface {})
@@ -1526,7 +1530,7 @@ func (dbclient *couchDatabase) batchUpdateDocuments(documents []*couchDoc) ([]*b
15261530 jsonDocumentMap = append (jsonDocumentMap , document )
15271531
15281532 }
1529-
1533+ couchdbLogger . Debugf ( "BatchUpdateDocuments() jsonDocumentMap=[%+v]" , jsonDocumentMap )
15301534 //Add the documents to the "docs" item
15311535 documentMap ["docs" ] = jsonDocumentMap
15321536
0 commit comments