@@ -146,7 +146,7 @@ DB.InitializeDatabase = function (options = {}) {
146146 // remap duplicate NODE IDs
147147 dupeNodes . forEach ( obj => {
148148 m_max_nodeID += 1 ;
149- LOGGER . Write ( PR , `# rewriting duplicate nodeID ${ obj . id } to ${ m_max_nodeID } ` ) ;
149+ LOGGER . WriteRLog ( { } , PR , `# rewriting duplicate nodeID ${ obj . id } to ${ m_max_nodeID } ` ) ;
150150 obj . id = m_max_nodeID ;
151151 } ) ;
152152
@@ -580,13 +580,12 @@ DB.PKT_GetDatabase = function (pkt) {
580580 if ( DBG )
581581 console . log (
582582 PR ,
583- `PKT_GetDatabase ${ pkt . Info ( ) } (loaded ${ nodes . length } nodes, ${
584- edges . length
583+ `PKT_GetDatabase ${ pkt . Info ( ) } (loaded ${ nodes . length } nodes, ${ edges . length
585584 } edges)`
586585 ) ;
587586 m_MigrateNodes ( nodes ) ;
588587 m_MigrateEdges ( edges ) ;
589- LOGGER . Write ( pkt . Info ( ) , `getdatabase` ) ;
588+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `getdatabase` ) ;
590589 return { d3data : { nodes, edges } , template : TEMPLATE } ;
591590} ;
592591/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -606,7 +605,7 @@ DB.PKT_SetDatabase = function (pkt) {
606605 console . log ( PR , `PKT_SetDatabase complete. Data available on next get.` ) ;
607606 m_db . close ( ) ;
608607 DB . InitializeDatabase ( ) ;
609- LOGGER . Write ( pkt . Info ( ) , `setdatabase` ) ;
608+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `setdatabase` ) ;
610609 return { OK : true } ;
611610} ;
612611/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -624,7 +623,7 @@ DB.PKT_InsertDatabase = function (pkt) {
624623 console . log ( PR , `PKT_InsertDatabase complete. Data available on next get.` ) ;
625624 m_db . close ( ) ;
626625 DB . InitializeDatabase ( ) ;
627- LOGGER . Write ( pkt . Info ( ) , `setdatabase` ) ;
626+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `setdatabase` ) ;
628627 return { OK : true } ;
629628} ;
630629/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -659,7 +658,7 @@ DB.PKT_MergeDatabase = function (pkt) {
659658 m_db . saveDatabase ( err => {
660659 if ( err ) reject ( new Error ( 'rejected' ) ) ;
661660 DB . InitializeDatabase ( ) ;
662- LOGGER . Write ( pkt . Info ( ) , `mergedatabase` ) ;
661+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `mergedatabase` ) ;
663662 resolve ( { OK : true } ) ;
664663 } )
665664 ) ;
@@ -679,7 +678,7 @@ DB.PKT_UpdateDatabase = function (pkt) {
679678 EDGES . update ( edges ) ;
680679 console . log ( PR , `PKT_UpdateDatabase complete. Disk db file updated.` ) ;
681680 m_db . saveDatabase ( ) ;
682- LOGGER . Write ( pkt . Info ( ) , `updatedatabase` ) ;
681+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `updatedatabase` ) ;
683682 return { OK : true } ;
684683} ;
685684/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -916,16 +915,15 @@ DB.PKT_Update = function (pkt) {
916915 node . id = m_GetNewNodeID ( ) ;
917916 }
918917
919- LOGGER . Write ( pkt . Info ( ) , `insert node` , node . id , JSON . stringify ( node ) ) ;
918+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `insert node` , node . id , JSON . stringify ( node ) ) ;
920919 DB . AppendNodeLog ( node , pkt ) ; // log GroupId to node stored in database
921920 NODES . insert ( node ) ;
922921 // Return the updated record -- needed to update metadata
923922 let updatedNode = NODES . findOne ( { id : node . id } ) ;
924923 if ( ! updatedNode )
925924 console . log (
926925 PR ,
927- `PKT_Update ${ pkt . Info ( ) } could not find node after update! This should not happen! ${
928- node . id
926+ `PKT_Update ${ pkt . Info ( ) } could not find node after update! This should not happen! ${ node . id
929927 } ${ JSON . stringify ( node ) } `
930928 ) ;
931929 retval = { op : 'insert' , node : updatedNode } ;
@@ -939,7 +937,7 @@ DB.PKT_Update = function (pkt) {
939937 node
940938 ) } `
941939 ) ;
942- LOGGER . Write ( pkt . Info ( ) , `update node` , node . id , JSON . stringify ( node ) ) ;
940+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `update node` , node . id , JSON . stringify ( node ) ) ;
943941 DB . AppendNodeLog ( n , pkt ) ; // log GroupId to node stored in database
944942 Object . assign ( n , node ) ;
945943 } ) ;
@@ -948,15 +946,14 @@ DB.PKT_Update = function (pkt) {
948946 if ( ! updatedNode )
949947 console . log (
950948 PR ,
951- `PKT_Update ${ pkt . Info ( ) } could not find node after update! This should not happen! ${
952- node . id
949+ `PKT_Update ${ pkt . Info ( ) } could not find node after update! This should not happen! ${ node . id
953950 } ${ JSON . stringify ( node ) } `
954951 ) ;
955952 retval = { op : 'update' , node : updatedNode } ;
956953 } else {
957954 if ( DBG )
958955 console . log ( PR , `WARNING: multiple nodeID ${ node . id } x${ matches . length } ` ) ;
959- LOGGER . Write ( pkt . Info ( ) , `ERROR` , node . id , 'duplicate node id' ) ;
956+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `ERROR` , node . id , 'duplicate node id' ) ;
960957 retval = { op : 'error-multinodeid' } ;
961958 }
962959 // Always update m_max_nodeID
@@ -982,16 +979,15 @@ DB.PKT_Update = function (pkt) {
982979 edge . id = m_GetNewEdgeID ( ) ;
983980 }
984981
985- LOGGER . Write ( pkt . Info ( ) , `insert edge` , edge . id , JSON . stringify ( edge ) ) ;
982+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `insert edge` , edge . id , JSON . stringify ( edge ) ) ;
986983 DB . AppendEdgeLog ( edge , pkt ) ; // log GroupId to edge stored in database
987984 EDGES . insert ( edge ) ;
988985 // Return the updated record -- needed to update metadata
989986 let updatedEdge = EDGES . findOne ( { id : edge . id } ) ;
990987 if ( ! updatedEdge )
991988 console . log (
992989 PR ,
993- `PKT_Update ${ pkt . Info ( ) } could not find node after update! This should not happen! ${
994- node . id
990+ `PKT_Update ${ pkt . Info ( ) } could not find node after update! This should not happen! ${ node . id
995991 } ${ JSON . stringify ( node ) } `
996992 ) ;
997993 retval = { op : 'insert' , edge : updatedEdge } ;
@@ -1001,11 +997,10 @@ DB.PKT_Update = function (pkt) {
1001997 if ( DBG )
1002998 console . log (
1003999 PR ,
1004- `PKT_Update ${ pkt . SourceGroupID ( ) } UPDATE edgeID ${
1005- edge . id
1000+ `PKT_Update ${ pkt . SourceGroupID ( ) } UPDATE edgeID ${ edge . id
10061001 } ${ JSON . stringify ( edge ) } `
10071002 ) ;
1008- LOGGER . Write ( pkt . Info ( ) , `update edge` , edge . id , JSON . stringify ( edge ) ) ;
1003+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `update edge` , edge . id , JSON . stringify ( edge ) ) ;
10091004 DB . AppendEdgeLog ( e , pkt ) ; // log GroupId to edge stored in database
10101005 Object . assign ( e , edge ) ;
10111006 } ) ;
@@ -1014,14 +1009,13 @@ DB.PKT_Update = function (pkt) {
10141009 if ( ! updatedEdge )
10151010 console . log (
10161011 PR ,
1017- `PKT_Update ${ pkt . Info ( ) } could not find node after update! This should not happen! ${
1018- node . id
1012+ `PKT_Update ${ pkt . Info ( ) } could not find node after update! This should not happen! ${ node . id
10191013 } ${ JSON . stringify ( node ) } `
10201014 ) ;
10211015 retval = { op : 'update' , edge : updatedEdge } ;
10221016 } else {
10231017 console . log ( PR , `WARNING: multiple edgeID ${ edge . id } x${ matches . length } ` ) ;
1024- LOGGER . Write ( pkt . Info ( ) , `ERROR` , node . id , 'duplicate edge id' ) ;
1018+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `ERROR` , node . id , 'duplicate edge id' ) ;
10251019 retval = { op : 'error-multiedgeid' } ;
10261020 }
10271021 // Always update m_max_edgeID
@@ -1034,7 +1028,7 @@ DB.PKT_Update = function (pkt) {
10341028 nodeID = m_CleanID ( `${ pkt . Info ( ) } nodeID` , nodeID ) ;
10351029 if ( DBG ) console . log ( PR , `PKT_Update ${ pkt . Info ( ) } DELETE nodeID ${ nodeID } ` ) ;
10361030 // Log first so it's apparent what is triggering the edge changes
1037- LOGGER . Write ( pkt . Info ( ) , `delete node` , nodeID ) ;
1031+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `delete node` , nodeID ) ;
10381032
10391033 // handle edges
10401034 let edgesToProcess = EDGES . where ( e => {
@@ -1049,27 +1043,27 @@ DB.PKT_Update = function (pkt) {
10491043 if ( replacementNodeID !== - 1 ) {
10501044 // re-link edges to replacementNodeID...
10511045 EDGES . findAndUpdate ( { source : nodeID } , e => {
1052- LOGGER . Write ( pkt . Info ( ) , `relinking edge` , e . id , `to` , replacementNodeID ) ;
1046+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `relinking edge` , e . id , `to` , replacementNodeID ) ;
10531047 e . source = replacementNodeID ;
10541048 } ) ;
10551049 EDGES . findAndUpdate ( { target : nodeID } , e => {
1056- LOGGER . Write ( pkt . Info ( ) , `relinking edge` , e . id , `to` , replacementNodeID ) ;
1050+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `relinking edge` , e . id , `to` , replacementNodeID ) ;
10571051 e . target = replacementNodeID ;
10581052 } ) ;
10591053 } else {
10601054 // ... or delete edges completely
10611055 let sourceEdges = EDGES . find ( { source : nodeID } ) ;
10621056 EDGES . findAndRemove ( { source : nodeID } ) ;
10631057 if ( sourceEdges . length )
1064- LOGGER . Write (
1065- pkt . Info ( ) ,
1058+ LOGGER . WriteRLog (
1059+ pkt . InfoObj ( ) ,
10661060 `deleting ${ sourceEdges . length } sources matching ${ nodeID } `
10671061 ) ;
10681062 let targetEdges = EDGES . find ( { target : nodeID } ) ;
10691063 EDGES . findAndRemove ( { target : nodeID } ) ;
10701064 if ( targetEdges . length )
1071- LOGGER . Write (
1072- pkt . Info ( ) ,
1065+ LOGGER . WriteRLog (
1066+ pkt . InfoObj ( ) ,
10731067 `deleting ${ targetEdges . length } targets matching ${ nodeID } `
10741068 ) ;
10751069 }
@@ -1082,7 +1076,7 @@ DB.PKT_Update = function (pkt) {
10821076 if ( edgeID !== undefined ) {
10831077 edgeID = m_CleanID ( `${ pkt . Info ( ) } edgeID` , edgeID ) ;
10841078 if ( DBG ) console . log ( PR , `PKT_Update ${ pkt . Info ( ) } DELETE edgeID ${ edgeID } ` ) ;
1085- LOGGER . Write ( pkt . Info ( ) , `delete edge` , edgeID ) ;
1079+ LOGGER . WriteRLog ( pkt . InfoObj ( ) , `delete edge` , edgeID ) ;
10861080 EDGES . findAndRemove ( { id : edgeID } ) ;
10871081 return { op : 'delete' , edgeID } ;
10881082 }
@@ -1409,24 +1403,24 @@ function m_MigrateEdges(edges) {
14091403function m_CleanObjID ( prompt , obj ) {
14101404 if ( typeof obj . id === 'string' ) {
14111405 let int = parseInt ( obj . id , 10 ) ;
1412- LOGGER . Write ( PR , `! ${ prompt } "${ obj . id } " is string; converting to ${ int } ` ) ;
1406+ LOGGER . WriteRLog ( { } , PR , `! ${ prompt } "${ obj . id } " is string; converting to ${ int } ` ) ;
14131407 obj . id = int ;
14141408 }
14151409 return obj ;
14161410}
14171411function m_CleanEdgeEndpoints ( prompt , edge ) {
14181412 if ( typeof edge . source === 'string' ) {
14191413 let int = parseInt ( edge . source , 10 ) ;
1420- LOGGER . Write (
1421- PR ,
1414+ LOGGER . WriteRLog (
1415+ { } , PR ,
14221416 ` edge ${ prompt } source "${ edge . source } " is string; converting to ${ int } `
14231417 ) ;
14241418 edge . source = int ;
14251419 }
14261420 if ( typeof edge . target === 'string' ) {
14271421 let int = parseInt ( edge . target , 10 ) ;
1428- LOGGER . Write (
1429- PR ,
1422+ LOGGER . WriteRLog (
1423+ { } , PR ,
14301424 ` edge ${ prompt } target "${ edge . target } " is string; converting to ${ int } `
14311425 ) ;
14321426 edge . target = int ;
@@ -1436,7 +1430,7 @@ function m_CleanEdgeEndpoints(prompt, edge) {
14361430function m_CleanID ( prompt , id ) {
14371431 if ( typeof id === 'string' ) {
14381432 let int = parseInt ( id , 10 ) ;
1439- LOGGER . Write ( PR , `! ${ prompt } "${ id } " is string; converting to number ${ int } ` ) ;
1433+ LOGGER . WriteRLog ( { } , PR , `! ${ prompt } "${ id } " is string; converting to number ${ int } ` ) ;
14401434 id = int ;
14411435 }
14421436 return id ;
0 commit comments