diff --git a/accounts.js b/accounts.js index a3864dd..5c651d7 100644 --- a/accounts.js +++ b/accounts.js @@ -12,7 +12,7 @@ var prettyprint = false; var url; function debug(message) { - dbg.message(" " + message,4); + logger.debug(" " + message); } function help() { diff --git a/experimental.js b/experimental.js index d10c2e4..bbeceef 100644 --- a/experimental.js +++ b/experimental.js @@ -72,21 +72,21 @@ function generateUUID(){ } function debug(message){ - dbg.message(" " + message,4); + logger.debug(" " + message); } function init(inDomainName, inUsername, inPassword,inTimeout,inPrettyprint){ - dbg.message("EXPERIMENTAL/UNSUPPORTED APIs - USE THESE AT YOUR OWN RISK",3); + logger.warn("EXPERIMENTAL/UNSUPPORTED APIs - USE THESE AT YOUR OWN RISK"); domainName = inDomainName; username = inUsername; password = inPassword; timeout = inTimeout; prettyprint = inPrettyprint; url = "https://" + domainName; - dbg.message("Username [" + username + "]",4); - dbg.message("URL [" + url + "]",4); - dbg.message("Timeout [" + timeout + "]",4); + logger.debug("Username [" + username + "]"); + logger.debug("URL [" + url + "]"); + logger.debug("Timeout [" + timeout + "]"); } @@ -100,10 +100,10 @@ function flowserviceDetails(inProjectId,includeEdgeFlows) function processflowDetails() { - debug("Process FlowService Details - Project [" + projectId + "] Include Edge flows [" + incEdgeFlows + "]"); + logger.debug("Process FlowService Details - Project [" + projectId + "] Include Edge flows [" + incEdgeFlows + "]"); var endPoint = "https://" +domainName + "/integration/rest/ut-flow/flow-metadata/" + projectId + "?limit=" + returnCount+ "&skip=" + returnStart; var body; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,body,undefined,"GET",processResponse,headers,true,false); } @@ -121,7 +121,7 @@ function flowserviceOption(inFlowServiceId, inEnable, inProjectId,inOptionType) function processflowOption() { var headers = setHeaders(); - debug("Process FlowService Option [" + flowOptionType + "] - Project [" + projectId + "] FlowService [" + flowServiceId + "] Enable [" + optionEnable + "]"); + logger.debug("Process FlowService Option [" + flowOptionType + "] - Project [" + projectId + "] FlowService [" + flowServiceId + "] Enable [" + optionEnable + "]"); if(optionEnable!==undefined&&optionEnable!==null&optionEnable.length>1){ optionEnable = (optionEnable.toLowerCase()=="true"); } @@ -134,7 +134,7 @@ function processflowOption() endPoint+= "/ut-flow/flow/export/" + flowServiceId +"?projectName="+ projectId ; body = {"integration":{"serviceData":{"stages":[{"stageName":"stage00","markExportable":optionEnable}]}}}; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); rest_fetch.custom(endPoint,undefined,undefined,timeout,body,undefined,"PUT",processResponse,headers,true,false); } @@ -170,10 +170,10 @@ function flowserviceScheduler(inFlowServiceId, inScheduleStatus, inProjectId) function processScheduleStatus() { - debug("Process FlowService Schedule Status - Project [" + projectId + "] FlowService [" + flowServiceId + "] Status [" + scheduleStatus + "]"); + logger.debug("Process FlowService Schedule Status - Project [" + projectId + "] FlowService [" + flowServiceId + "] Status [" + scheduleStatus + "]"); var endPoint = "https://" +domainName + "/integration/rest/scheduler/"+ scheduleStatus +"/" + flowServiceId +"?projectName="+ projectId ; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); var body; rest_fetch.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processResponse,headers,true,false); @@ -221,7 +221,7 @@ function getProjectAccountConfig(inProjectId) function projectDeployments(inProjectId) { - dbg.message("Listing project deployments for projectId [" + inProjectId + "]",4); + logger.debug("Listing project deployments for projectId [" + inProjectId + "]"); projectId = inProjectId; finalCall = getProjectDeployments; loginPhase1(); @@ -254,7 +254,7 @@ function messagingSubscriberDisable(inProjectId,inSubscriberName){ } function messagingSubscriber(inProjectId,inSubscriberName,state){ - debug("Starting subscriber state change"); + logger.debug("Starting subscriber state change"); projectId = inProjectId; subscriberName = inSubscriberName; subscriberState = state; @@ -312,12 +312,12 @@ function vbidAnalysis(inVbid, inFormat) function debugMonitorInfo() { - debug("Monitor Project: [" + projectName + "]"); - debug("Monitor Project ID: [" + projectId + "]"); - debug("Monitor workflowId: [" + workflowId + "]"); - debug("Monitor executionStatus: [" + executionStatus + "]"); - debug("Monitor startDate: [" + startDate + "]"); - debug("Monitor endDate: [" + endDate + "]"); + logger.debug("Monitor Project: [" + projectName + "]"); + logger.debug("Monitor Project ID: [" + projectId + "]"); + logger.debug("Monitor workflowId: [" + workflowId + "]"); + logger.debug("Monitor executionStatus: [" + executionStatus + "]"); + logger.debug("Monitor startDate: [" + startDate + "]"); + logger.debug("Monitor endDate: [" + endDate + "]"); } function processMonitorBody() @@ -376,9 +376,9 @@ function setHeaders() function getVbidAnalysis() { - dbg.message("Getting VBID analysis [" + vbid + "]"); + logger.info("Getting VBID analysis [" + vbid + "]"); var endPoint = "https://" + domainName + "/enterprise/v1/tenant/logs/" + vbid + "?field=created_at&direction=asc"; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processVbidResponse,headers,true,false); @@ -386,11 +386,11 @@ function getVbidAnalysis() function checkResubmissions() { - debug("Check Resubmissions") + logger.debug("Check Resubmissions") debugMonitorInfo(); //Check running var endPoint = "https://" + domainName + "/enterprise/v1/metrics/workflowexecutions/logs"; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var body=processMonitorBody(); body.execution_status=["running"]; var headers = setHeaders(); @@ -398,11 +398,11 @@ function checkResubmissions() } function processResubmissions(fetchSize,reprocessCount){ - debug("Process Resubmissions") + logger.debug("Process Resubmissions") debugMonitorInfo(); //Check running var endPoint = "https://" + domainName + "/enterprise/v1/metrics/workflowexecutions/logs"; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var body=processMonitorBody(); body.limit=reprocessCount; body.execution_status=["failed"]; @@ -411,31 +411,31 @@ function processResubmissions(fetchSize,reprocessCount){ } function processSingleResubmission(a,b, invbid){ - dbg.message("Processing Resubmission [" + (a+1) + " of " + b + "] Action [" + startOrResume + "] VBID [" + invbid + "]",3); + logger.info("Processing Resubmission [" + (a+1) + " of " + b + "] Action [" + startOrResume + "] VBID [" + invbid + "]"); var endPoint = "https://" + domainName + "/enterprise/v1/tenant/account/billlogs/" + invbid; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processSingleResubmissionResponse,headers,true,false); } function getThePayload(invbid){ - dbg.message("" + invbid + ":Fetching Payload For Restart - VBID [" + invbid + "]",4); + logger.debug("" + invbid + ":Fetching Payload For Restart - VBID [" + invbid + "]"); var endPoint = "https://" + domainName + "/enterprise/v1/payloads?bill_uid=" + invbid - dbg.message("" +invbid + ":getThePayload Next URL [" + endPoint + "]"); + logger.debug("" +invbid + ":getThePayload Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processPayloadResponse,headers,true,false); } function finishProcessSingleResubmission(invbid,inwfuid,inPayloaduid,projectuid,data) { - dbg.message("" +invbid + ":Actioning Resubmission Action [" + startOrResume + "] VBID [" + invbid + "]",4); + logger.debug("" +invbid + ":Actioning Resubmission Action [" + startOrResume + "] VBID [" + invbid + "]"); var endPoint if (startOrResume == "resume") endPoint = "https://" + domainName + "/enterprise/v1/execute/" + inwfuid + "/resume"; else endPoint = "https://" + domainName + "/enterprise/v1/execute/" + invbid + "/restart"; - dbg.message("" +invbid + ":Next URL [" + endPoint + "]",4); + logger.debug("" +invbid + ":Next URL [" + endPoint + "]"); var headers = setHeaders(); var body; if(startOrResume=="resume"){ @@ -452,43 +452,43 @@ function processPayloadResponse(url,err,body,res){ if(res.status==200) { data={}; - dbg.message("Processing Payload Response",4); - dbg.message("URL" + url,4); - if(body)dbg.message("JSON RESP\n" + JSON.stringify(body),4); - if(res) dbg.message("RES\n" + JSON.stringify(res),4); + logger.debug("Processing Payload Response"); + logger.debug("URL" + url); + if(body)logger.debug("JSON RESP\n" + JSON.stringify(body)); + if(res) logger.debug("RES\n" + JSON.stringify(res)); if(body.output.length==1 && body.output[0].data){ data = body.output[0].data; } else { - dbg.message("Found no payload response",4); - if(body!=null)dbg.message(JSON.stringify(body),4); + logger.debug("Found no payload response"); + if(body!=null)logger.debug(JSON.stringify(body)); } if(body.output.length==1 && body.output[0].type) { type = body.output[0].type; - if(body)dbg.message("Payload Resp: " + JSON.stringify(body),4); + if(body)logger.debug("Payload Resp: " + JSON.stringify(body)); finishProcessSingleResubmission(vbid,flowuid,payloaduid,projectuid,data); } else{ - if(body!=null)dbg.message(JSON.stringify(body),2); - dbg.message("Unable to determine type",2); + if(body!=null)logger.warn(JSON.stringify(body)); + logger.warn("Unable to determine type"); } } else { - dbg.message("Failed to " + "restart" + " entry",1) - if(body!=null)dbg.message(JSON.stringify(body),1); - if(err!=null)dbg.message(JSON.stringify(err),1); + logger.fatal("Failed to " + "restart" + " entry") + if(body!=null)logger.fatal(JSON.stringify(body)); + if(err!=null)logger.fatal(JSON.stringify(err)); process.exit(99); } } function processFinalSingleResubmissionResponse(url,err,body,res){ - if(body!=null)dbg.message(" Submission Resp:" + JSON.stringify(body),4); + if(body!=null)logger.debug(" Submission Resp:" + JSON.stringify(body)); if(res.status==200) { var respvbid,respstatus; @@ -501,13 +501,13 @@ function processFinalSingleResubmissionResponse(url,err,body,res){ respstatus = body.output.status; } - dbg.message("Processed VBID: " + respvbid + " - New Status [" + respstatus + "]",3); + logger.info("Processed VBID: " + respvbid + " - New Status [" + respstatus + "]"); } else { - dbg.message("Failed to " + startOrResume + " Monitor item",1) - if(body!=null)dbg.message("" + JSON.stringify(body),1); - if(err!=null)dbg.message(""+ JSON.stringify(err),1); + logger.fatal("Failed to " + startOrResume + " Monitor item") + if(body!=null)logger.fatal("" + JSON.stringify(body)); + if(err!=null)logger.fatal(""+ JSON.stringify(err)); process.exit(99); } } @@ -521,7 +521,7 @@ function logsToCSV(logsJson){ var sep = ","; for(var i=0;i"+"CSV Conversion [" + i + "]",4); + logger.debug(""+"CSV Conversion [" + i + "]"); activityId = logsJson.output.objects[i].activity_id; activityLabel = logsJson.output.objects[i].activity_label; activityType = logsJson.output.objects[i].type; @@ -545,7 +545,7 @@ function logsToCSV(logsJson){ csv += activityId + sep + activityLabel + sep + activityType + sep + message + sep + actionDate + sep; if(i>0) { - dbg.message(""+"CSV Conversion Calculating delta",4); + logger.debug(""+"CSV Conversion Calculating delta"); var dateObjPrev = new Date(prevDate); var dateObjCurr = new Date(actionDate); var res = dateObjCurr.getTime() - dateObjPrev.getTime(); @@ -569,7 +569,7 @@ function processVbidResponse(url,err,body,res){ { if(body.output.objects) { - dbg.message(""+"Found Logs for - VBID",4); + logger.debug(""+"Found Logs for - VBID"); var outputFormat = format.toUpperCase(); @@ -577,22 +577,22 @@ function processVbidResponse(url,err,body,res){ { case "JSON": - dbg.message(""+"Outputting in JSON Format",4); + logger.debug(""+"Outputting in JSON Format"); if(prettyprint==true){ - dbg.message(JSON.stringify(body,null,4),-1); + console.log(JSON.stringify(body,null,4)); } else{ - dbg.message((JSON.stringify(body)),-1); + console.log(JSON.stringify(body)); } break; case "CSV": - dbg.message(""+"Outputting in CSV Format",4); + logger.debug(""+"Outputting in CSV Format"); var csv = logsToCSV(body); - dbg.message(csv,-1); + console.log(csv); break; default: - dbg.message("" + "Please provide a valid format - either JSON or CSV"); + logger.debug("" + "Please provide a valid format - either JSON or CSV"); break; } @@ -601,13 +601,13 @@ function processVbidResponse(url,err,body,res){ } else{ - dbg.message(""+ "Unable to find logs for VBID",1); + logger.fatal(""+ "Unable to find logs for VBID"); } } else { - dbg.message(""+"Failed to get logs for VBID",1) - dbg.message(JSON.stringify(body),1); + logger.fatal(""+"Failed to get logs for VBID") + console.log(JSON.stringify(body)); process.exit(99); } } @@ -618,16 +618,16 @@ function processSingleResubmissionResponse(url,err,body,res){ { if(body.output.uid) { - dbg.message(""+"Found Monitor Entry - VBID[" + body.output.uid +"]",4); - dbg.message(""+"Flow UID [" + body.output.flow_uid + "]",4); - dbg.message(""+"Payload UID [" + body.output.payload_uid + "]",4); - dbg.message(""+"Project_UID [" + body.output.project_uid + "]",4); - dbg.message(""+"Flow Name [" + body.output.flow_name + "]",4); - dbg.message(""+"Stop time [" + body.output.stop_time + "]",4); - dbg.message(""+"Restarted [" + body.output.restarted + "]",4) - dbg.message(""+"Manual Run [" + body.output.manual_run + "]",4) - dbg.message(""+"hide_resume [" + body.output.hide_resume + "]",4) - dbg.message(""+"JSON RESPONSE\n" + JSON.stringify(body) + "\n",4); + logger.debug(""+"Found Monitor Entry - VBID[" + body.output.uid +"]"); + logger.debug(""+"Flow UID [" + body.output.flow_uid + "]"); + logger.debug(""+"Payload UID [" + body.output.payload_uid + "]"); + logger.debug(""+"Project_UID [" + body.output.project_uid + "]"); + logger.debug(""+"Flow Name [" + body.output.flow_name + "]"); + logger.debug(""+"Stop time [" + body.output.stop_time + "]"); + logger.debug(""+"Restarted [" + body.output.restarted + "]") + logger.debug(""+"Manual Run [" + body.output.manual_run + "]") + logger.debug(""+"hide_resume [" + body.output.hide_resume + "]") + logger.debug(""+"JSON RESPONSE\n" + JSON.stringify(body) + "\n"); @@ -639,24 +639,24 @@ function processSingleResubmissionResponse(url,err,body,res){ if(startOrResume.indexOf("restart")==0){ - debug("In restart procedure"); + logger.debug("In restart procedure"); if(body.output.manual_run == true){ - dbg.message(""+ "Skipped [" + body.output.uid + "]. Restart Not Available",2); + logger.warn(""+ "Skipped [" + body.output.uid + "]. Restart Not Available"); } else { if(startOrResume=="restart-all"){ - debug("is a restart all)"); - if(body.output.restarted==true)dbg.message(""+ "Restarting [" + body.output.uid + "] when this has been done previously.",2); + logger.debug("is a restart all)"); + if(body.output.restarted==true)logger.warn(""+ "Restarting [" + body.output.uid + "] when this has been done previously."); getThePayload(body.output.uid); } else{ - debug("is a normal restart)"); + logger.debug("is a normal restart)"); if(body.output.restarted != true){ - dbg.message(""+ "Restarting [" + body.output.uid + "]",4); + logger.debug(""+ "Restarting [" + body.output.uid + "]"); getThePayload(body.output.uid); } else{ - dbg.message(""+ "Skipped [" + body.output.uid + "]. Has been restarted previously. Use restart-all as the option if you need to restart this",2); + logger.warn(""+ "Skipped [" + body.output.uid + "]. Has been restarted previously. Use restart-all as the option if you need to restart this"); } } } @@ -664,25 +664,25 @@ function processSingleResubmissionResponse(url,err,body,res){ if(startOrResume=="resume"){ if(body.output.hide_resume == false){ - dbg.message(""+ "Resuming [" + body.output.uid + "]",4); + logger.debug(""+ "Resuming [" + body.output.uid + "]"); finishProcessSingleResubmission(body.output.uid,body.output.flow_uid,body.output.payload_uid,body.output.project_uid); } else { - dbg.message(""+ "Skipped [" + body.output.uid + "]. Resume is not available",4); + logger.debug(""+ "Skipped [" + body.output.uid + "]. Resume is not available"); } } } else{ - dbg.message(""+ "Not able to find monitor entry",1); + logger.error(""+ "Not able to find monitor entry"); } } else { - dbg.message(""+"Failed to get Monitor entry",1) - dbg.message(JSON.stringify(body),1); + logger.fatal(""+"Failed to get Monitor entry") + console.log(JSON.stringify(body)); process.exit(99); } } @@ -696,12 +696,12 @@ function processListResponse(url,err,body,res){ //... do something next if(body.output.count==0) { - dbg.message(""+"No Workflows To Resubmit",3); + logger.warn(""+"No Workflows To Resubmit"); process.exit(0); } else{ - dbg.message(""+"Workflow Instances To Resubmit [" + body.output.logs.length + " of " + body.output.count + "]",3); + logger.info(""+"Workflow Instances To Resubmit [" + body.output.logs.length + " of " + body.output.count + "]"); for(var i=0;i"+"Failed to get Running Workflows",1) - if(body!=null)dbg.message(JSON.stringify(body),1); - if(err!=null)dbg.message(JSON.stringify(err),2); + logger.error(""+"Failed to get Running Workflows") + if(body!=null)logger.fatal(JSON.stringify(body)); + if(err!=null)console.log(JSON.stringify(err)); process.exit(99); } } @@ -722,69 +722,69 @@ function processRunningResponse(url,err,body,res){ if(res.status==200){ //... do something next if(body.output.count==0){ - dbg.message(""+"No Workflows Running",3) - dbg.message(""+"Can Resubmit [" + (maxRunningWorkflows - body.output.count) + "] executions",3); + logger.info(""+"No Workflows Running") + logger.info(""+"Can Resubmit [" + (maxRunningWorkflows - body.output.count) + "] executions"); } else{ - dbg.message(""+"Workflows Running [" +body.output.count + "]",3) + logger.info(""+"Workflows Running [" +body.output.count + "]") if(body.output.count"+"Can Resubmit [" + (maxRunningWorkflows - body.output.count) + "] executions",3); + logger.info(""+"Can Resubmit [" + (maxRunningWorkflows - body.output.count) + "] executions"); } else{ - dbg.message(""+"Maximum Workflow Executions Currently in progress - exiting",2); + logger.warn(""+"Maximum Workflow Executions Currently in progress - exiting"); process.exit(0); } } processResubmissions(100, maxRunningWorkflows - body.output.count); } else{ - dbg.message(""+"Failed to get Running Workflows",1) - if(body!=null)dbg.message(JSON.stringify(body),1); - if(err!=null)dbg.message(JSON.stringify(err),2); + logger.fatal(""+"Failed to get Running Workflows") + if(body!=null)logger.error(JSON.stringify(body)); + if(err!=null)console.log(JSON.stringify(err)); process.exit(99); } } function doMessagingCreate() { - debug("Messaging Item Creation") + logger.debug("Messaging Item Creation") var endPoint = "https://" +domainName + "/integration/rest/messaging/admin/destinations?projectName=" + projectId + "&type=" + queueOrTopic; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var body; if(queueOrTopic=="queue")body={"queueName":messagingName}; else if (queueOrTopic=="topic")body={"topicName":messagingName} - else dbg.message(""+"Please provide either 'queue' or 'topic'",1); + else logger.fatal(""+"Please provide either 'queue' or 'topic'"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processResponse,headers,true,false); } function processSubscriberState() { - debug("Messaging Subscriber State Change: " + subscriberState); + logger.debug("Messaging Subscriber State Change: " + subscriberState); var endPoint = "https://" +domainName + "/integration/rest/messaging/subscribers/" + subscriberName + "?projectName=" + projectId + "&prop=state&value=" + subscriberState + "&force=false"; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"PATCH",processResponse,headers,true,false); } function doMessagingDelete() { - debug("Messaging Item Deletion") + logger.debug("Messaging Item Deletion") var endPoint = "https://" +domainName + "/integration/rest/messaging/admin/destinations/" + messagingName + "?projectName=" + projectId + "&type=" + queueOrTopic; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var body; if(queueOrTopic=="queue")body={"queueName":messagingName}; else if (queueOrTopic=="topic")body={"topicName":messagingName} - else dbg.message(""+"Please provide either 'queue' or 'topic'",1); + else logger.fatal(""+"Please provide either 'queue' or 'topic'"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,60,body,undefined,"DELETE",processResponse,headers,true,false); } function getMessagingStats() { - debug("Messaging Stats"); + logger.debug("Messaging Stats"); var endPoint = "https://" +domainName + "/integration/rest/messaging/runtime/destinations/"+messagingName+"/metrics?projectName=" + projectId ; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); var body; rest_fetch.custom(endPoint,undefined,undefined,timeout,body,undefined,"GET",processResponse,headers,true,false); @@ -794,7 +794,7 @@ function getLogs() { debugMonitorInfo(); var endPoint = "https://" + domainName + "/enterprise/v1/metrics/workflowexecutions/logs"; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var body=processMonitorBody(); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,body,undefined,"POST",processResponse,headers,true,false); @@ -803,9 +803,9 @@ function getLogs() function searchProjectsByName() { - dbg.message(""+"Search Projects By Name [" + projectName + "]",4); + logger.debug(""+"Search Projects By Name [" + projectName + "]"); var endPoint = "https://" + domainName + "/enterprise/v1/projects?limit=" + returnCount+ "&skip=" + returnStart + "&q=" + projectName; - dbg.message(""+"Next URL [" + endPoint + "]",4); + logger.debug(""+"Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,headers,true,false); @@ -813,27 +813,27 @@ function searchProjectsByName() function getProjectDeployments() { - dbg.message(""+"Executing Project Deployments call",4); + logger.debug("Executing Project Deployments call"); var endPoint = "https://" + domainName + "/enterprise/v1/deployments"; - dbg.message(""+"Next URL [" + endPoint + "]",4); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,headers,true,false); } function stageInfo() { - debug("Stage Info"); + logger.debug("Stage Info"); var endPoint = "https://" + domainName + "/enterprise/v1/stages?allRegion=false"; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,headers,true,false); } function getProjectAccountConfigInfo() { - debug("Project Account Config Info"); + logger.debug("Project Account Config Info"); var endPoint = "https://" + domainName + "/enterprise/v1/configdata"; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,headers,true,false); } @@ -841,9 +841,9 @@ function getProjectAccountConfigInfo() function usedConnectorAccountsInfo() { - debug("Used Connectors Info"); + logger.debug("Used Connectors Info"); var endPoint = "https://" + domainName + "/enterprise/v1/user/auths"; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,headers,true,false); } @@ -851,9 +851,9 @@ function usedConnectorAccountsInfo() function projectWorkflowsInfo() { - debug("Project Workflows Info"); + logger.debug("Project Workflows Info"); var endPoint = "https://" + domainName + "/enterprise/v1/flows?limit=" + returnCount+ "&skip=" + returnStart + "&filter=recent&tags=&query="; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processProjectsResponse,headers,true,false); } @@ -861,9 +861,9 @@ function projectWorkflowsInfo() function projectFlowServicesInfo() { - debug("Project FlowServices Info"); + logger.debug("Project FlowServices Info"); var endPoint = "https://" + domainName + "/integration/rest/ut-flow/flow-metadata/" + projectId + "?limit=" + returnCount+ "&skip=" + returnStart; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,headers,true,false); } @@ -871,9 +871,9 @@ function projectFlowServicesInfo() function execUserInfo() { - debug(""+"Exec User Info"); + logger.debug(""+"Exec User Info"); var endPoint = "https://" + domainName + "/enterprise/v1/user"; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = setHeaders(); rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",processResponse,headers,true,false); } @@ -881,7 +881,7 @@ function execUserInfo() /** Logs in via Software AG Cloud! */ function loginPhase1() { - debug("LOGIN Phase 1") + logger.debug("LOGIN Phase 1") var endPoint = url + "/integration/sagcloud/"; rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",loginResponse,undefined,true,false); @@ -889,18 +889,18 @@ function loginPhase1() function loginPhase2() { - debug("LOGIN Phase 2") + logger.debug("LOGIN Phase 2") var endPoint = nextUrl; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); formUrl = endPoint; rest_fetch.custom(endPoint,undefined,undefined,timeout,undefined,undefined,"GET",loginResponse,undefined,false,false); } function loginPhase3() { - debug("LOGIN Phase 3") + logger.debug("LOGIN Phase 3") var endPoint = nextUrl; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = [ {name:"Referer",value:formUrl}, @@ -932,9 +932,9 @@ function loginPhase3() function loginRedirectPhase(inId) { - debug("LOGIN (Redirect) Phase " + inId); + logger.debug("LOGIN (Redirect) Phase " + inId); var endPoint = nextUrl; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = [ {name:"Accept",value:"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}, @@ -944,9 +944,9 @@ function loginRedirectPhase(inId) function loginUserPhase(inId) { - debug("LOGIN (USER) Phase " + inId); + logger.debug("LOGIN (USER) Phase " + inId); var endPoint = "https://" + domainName + "/enterprise/v1/user"; - debug("Next URL [" + endPoint + "]"); + logger.debug("Next URL [" + endPoint + "]"); var headers = [ {name:"authtoken",value:authtoken}, @@ -957,33 +957,33 @@ function loginUserPhase(inId) function checkResponse(res,body) { - debug("Response Status Code =" + res.status); + logger.debug("Response Status Code =" + res.status); if(res.status == 302){ //nextUrl = res.headers.location; nextUrl = res.headers.raw()['location']; - debug("Redirect URL [" + nextUrl + "]"); + logger.debug("Redirect URL [" + nextUrl + "]"); return; } if(res.status == 200){ - debug(body); + logger.debug(body); return; } if(res.status == 400 || res.status == 404 || res.status == 500 || res.status == 502 || res.status == 403 || res.status == 401) { - dbg.message("Failed to login via Software AG Cloud - exiting",4) - dbg.message(res,4); + logger.debug("Failed to login via Software AG Cloud - exiting"); + console.log(res); process.exit(99); } } function checkPhase3Response(res,body) { - debug("Response Status Code =" + res.status); + logger.debug("Response Status Code =" + res.status); if(res.status == 302){ nextUrl = res.headers.raw()['location']; - debug("Redirect URL [" + nextUrl + "]"); + logger.debug("Redirect URL [" + nextUrl + "]"); } if(res.status == 200){ @@ -995,16 +995,15 @@ function checkPhase3Response(res,body) error ={} error.message = err; - dbg.message("Failed to login via Software AG Cloud [" + err + "] - exiting",4) - dbg.message(JSON.stringify(error),4); - + logger.warn("Failed to login via Software AG Cloud [" + err + "] - exiting") + console.log(JSON.stringify(error)); process.exit(401); } if(res.status == 400 || res.status == 404 || res.status == 500 || res.status == 502 || res.status == 403 || res.status == 401) { - dbg.message("Failed to login via Software AG Cloud - exiting",4) - dbg.message(res,4); + logger.warn("Failed to login via Software AG Cloud - exiting") + console.log(res); process.exit(99); } } @@ -1033,15 +1032,15 @@ function processProjectsResponse(url,err,body,res){ if(prettyprint==true){ - dbg.message(JSON.stringify(output,null,4),-1); + console.log(JSON.stringify(output,null,4)); } else{ - dbg.message((JSON.stringify(output)),-1); + console.log((JSON.stringify(output))); } } else { - dbg.message("Failed to login via Software AG Cloud - exiting",4) + logger.warn("Failed to login via Software AG Cloud - exiting") process.exit(99); } } @@ -1050,17 +1049,16 @@ function processResponse(url,err,body,res){ if(res.status==200) { if(prettyprint==true){ - dbg.message(JSON.stringify(body,null,4),-1); + console.log(JSON.stringify(body,null,4)); } else{ - dbg.message((JSON.stringify(body)),-1); + console.log((JSON.stringify(body))); } } else { - //dbg.message("Failed to login via Software AG Cloud - exiting",4) - if(body!==null)dbg.message((JSON.stringify(body)),-1); - else dbg.message("Failed to login via Software AG Cloud - exiting",4) + if(body!==null)console.log((JSON.stringify(body))); + else logger.warn("Failed to login via Software AG Cloud - exiting"); process.exit(99); } } @@ -1072,14 +1070,14 @@ function processUserResponse(url,err,body,res){ } else { - debug("Failed to login via Software AG Cloud - exiting") + logger.warn("Failed to login via Software AG Cloud - exiting") process.exit(99); } //Now run the final call - dbg.message("Logged in",3); + logger.info("Logged in"); if(finalCall!==undefined)finalCall(); - else dbg.message("No final call set",4); + else logger.error("No final call set"); } @@ -1091,18 +1089,18 @@ function loginResponse(url,err,body,res){ //Check on origin to determine action var origin = domainName + "/integration/sagcloud/"; - debug("Origin was [" + origin + "]"); - debug("On stage: " +loginStageCounter ); + logger.debug("Origin was [" + origin + "]"); + logger.debug("On stage: " +loginStageCounter ); switch(loginStageCounter) { case 1: - debug("Phase 1"); + logger.debug("Phase 1"); checkResponse(res,body); nextCall = loginPhase2(); break; case 2: - debug("Phase 2"); + logger.debug("Phase 2"); checkResponse(res,body); //Parse Next URL from HTML Form @@ -1116,35 +1114,35 @@ function loginResponse(url,err,body,res){ break; case 3: - debug("Phase 3"); + logger.debug("Phase 3"); checkPhase3Response(res,body); nextCall = loginRedirectPhase(4); break; case 4: - debug("Phase 4"); + logger.debug("Phase 4"); checkResponse(res,body); nextCall = loginRedirectPhase(5); break; case 5: - debug("Phase 5"); + logger.debug("Phase 5"); checkResponse(res,body); nextCall = loginRedirectPhase(6); break; case 6: - debug("Phase 6"); + logger.debug("Phase 6"); checkResponse(res,body); - debug("checked response - processing nextUrl"); + logger.debug("checked response - processing nextUrl"); var workOn = nextUrl.toString(); - debug("Next URL is: [" + workOn + "]"); - debug(workOn.indexOf('/#/sso/success')); + logger.debug("Next URL is: [" + workOn + "]"); + logger.debug(workOn.indexOf('/#/sso/success')); if(workOn.indexOf('/#/sso/success')==0) { - debug("Getting Authtoken details"); + logger.debug("Getting Authtoken details"); authtoken = workOn.split("?sid=")[1].split("&")[0]; uid = workOn.split("&tenant_uid=")[1]; - debug("authtoken [" + authtoken +"]"); - debug("tenantuid [" + uid +"]"); + logger.debug("authtoken [" + authtoken +"]"); + logger.debug("tenantuid [" + uid +"]"); nextCall=loginUserPhase(7); } @@ -1155,7 +1153,7 @@ function loginResponse(url,err,body,res){ //Invoke next call in chain if(nextCall!==undefined) { - debug("Found target call... initiating"); + logger.debug("Found target call... initiating"); nextCall(); } diff --git a/flowservice.js b/flowservice.js index 22955ca..48807c8 100644 --- a/flowservice.js +++ b/flowservice.js @@ -5,14 +5,12 @@ */ const rest = require('./rest-fetch.js'); -const dbg = require('./debug.js'); - var domainName, username,password,timeout,prettyprint; var url; function debug(message){ - dbg.message(" " + message,4); + logger.debug(" " + message); } function help(){ diff --git a/idm.js b/idm.js index c5a8fa7..62c6d25 100644 --- a/idm.js +++ b/idm.js @@ -13,7 +13,7 @@ var url; var bearerToken; function debug(message) { - dbg.message(" " + message,4); + logger.debug(" " + message); } function help() { return ` diff --git a/monitor.js b/monitor.js index 73aa927..5be4e83 100644 --- a/monitor.js +++ b/monitor.js @@ -12,7 +12,7 @@ var prettyprint = false; var url; function debug(message) { - dbg.message(" " + message,4); + logger.debug(" " + message); } function help() { diff --git a/package-lock.json b/package-lock.json index 692820f..76e2e7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "formdata-node": "^6.0.3", "https-proxy-agent": "^7.0.4", + "log4js": "^6.9.1", "node-fetch": "^3.3.2", "readline-sync": "^1.4.10", "tough-cookie": "^4.1.4" @@ -53,6 +54,15 @@ "node": ">= 12" } }, + "node_modules/date-format": { + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", + "integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==", + "license": "MIT", + "engines": { + "node": ">=4.0" + } + }, "node_modules/debug": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", @@ -93,6 +103,12 @@ "node": "^12.20 || >= 14.13" } }, + "node_modules/flatted": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", + "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "license": "ISC" + }, "node_modules/formdata-node": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-6.0.3.tgz", @@ -114,6 +130,35 @@ "node": ">=12.20.0" } }, + "node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/fs-extra/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "license": "MIT", + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "license": "ISC" + }, "node_modules/https-proxy-agent": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz", @@ -127,6 +172,31 @@ "node": ">= 14" } }, + "node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "license": "MIT", + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/log4js": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.9.1.tgz", + "integrity": "sha512-1somDdy9sChrr9/f4UlzhdaGfDR2c/SaD2a4T7qEkG4jTS57/B3qmnjLYePwQ8cqWnUHZI0iAKxMBpCZICiZ2g==", + "license": "Apache-2.0", + "dependencies": { + "date-format": "^4.0.14", + "debug": "^4.3.4", + "flatted": "^3.2.7", + "rfdc": "^1.3.0", + "streamroller": "^3.1.5" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -206,6 +276,26 @@ "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", "license": "MIT" }, + "node_modules/rfdc": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.1.tgz", + "integrity": "sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg==", + "license": "MIT" + }, + "node_modules/streamroller": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.1.5.tgz", + "integrity": "sha512-KFxaM7XT+irxvdqSP1LGLgNWbYN7ay5owZ3r/8t77p+EtSUAfUgtl7be3xtqtOmGUl9K9YPO2ca8133RlTjvKw==", + "license": "MIT", + "dependencies": { + "date-format": "^4.0.14", + "debug": "^4.3.4", + "fs-extra": "^8.1.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/tough-cookie": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz", diff --git a/package.json b/package.json index 7725624..2ed9312 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "dependencies": { "formdata-node": "^6.0.3", "https-proxy-agent": "^7.0.4", + "log4js": "^6.9.1", "node-fetch": "^3.3.2", "readline-sync": "^1.4.10", "tough-cookie": "^4.1.4" diff --git a/projects.js b/projects.js index 275cfcf..ae2890d 100644 --- a/projects.js +++ b/projects.js @@ -12,7 +12,7 @@ var prettyprint = false; var url; function debug(message) { - dbg.message(" " + message,4); + logger.debug(" " + message,4); } function help() { diff --git a/recipe.js b/recipe.js index 5e7d830..aace3cd 100644 --- a/recipe.js +++ b/recipe.js @@ -10,7 +10,7 @@ var domainName, username, password, timeout, prettyprint; var url; function debug(message) { - dbg.message(" " + message,4); + logger.debug(" " + message); } function help() { return ` diff --git a/rest-fetch.js b/rest-fetch.js index 6247071..86a4b4f 100644 --- a/rest-fetch.js +++ b/rest-fetch.js @@ -8,36 +8,30 @@ const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); const { CookieJar } = require('tough-cookie'); -const zlib = require('zlib'); +//const zlib = require('zlib'); const fs = require ('fs') const { FormData } = require('formdata-node'); const { fileFromPathSync } = require('formdata-node/file-from-path'); const { HttpsProxyAgent }= require('https-proxy-agent'); var proxyAgent = undefined; -const { message } = require('./debug'); -const { warn } = require('console'); const cj = new CookieJar(); var cookieJar = []; var domain -function consolelog(message,level) -{ - dbg.message(":" + message,level); -} function debug(message){ - consolelog(message,4); + logger.debug(message); } function info(message){ - consolelog(message,3); + logger.info(message); } function warning(message){ - consolelog(message,2); + logger.warn(message); } function error(message){ - consolelog(message,1); + logger.error(message); } @@ -67,17 +61,18 @@ function addCookieToJar(cookie,domainName) function displayCookies() { warning("------------------------- COOKIES -------------------------"); - warning(`⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⠴⠶⠦⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ - ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣴⡯⠤⠴⠶⠶⠶⠿⠷⠶⠶⠦⠤⣴⠚⠛⠒⠶⣤⡀⠀⠀⠀⠀⠀⠀⠀ - ⠀⠀⠀⠀⢀⣀⣠⣄⣤⠶⢚⣯⠭⠤⠶⠤⢤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⢦⣀⡀⠀⠈⢹⣆⠀⠀⠀⠀⠀⠀ - ⠀⢀⡴⠞⠉⠀⠀⢀⡟⠀⢯⣄⣀⣀⣀⣀⣠⠿⠀⠀⢀⡤⠤⠒⠒⠒⠶⢤⡀⠈⠉⠉⣉⣭⣭⣗⣦⣄⡀⠀⠀ - ⠀⣟⣀⣀⣠⠴⠞⠉⠀⡠⠤⠶⠾⣍⡭⠥⠤⠤⣀⠀⠘⢧⣀⠀⠀⠀⠀⣀⣽⣀⣀⣈⣧⡀⠀⠀⠈⠙⢿⣦⡀ - ⣰⠋⠁⠀⠀⣀⣀⡀⠀⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⡹⠛⠉⠀⠀⠈⠉⠻⣗⠲⠦⠤⠾⠋⢷ - ⡏⠀⣴⠋⠉⠁⠈⠉⣳⠀⠀⠀⢀⣠⠤⠶⠦⠤⣄⡀⠀⠀⠀⠀⠀⣀⠤⠴⠶⠦⣤⡀⠀⠀⠈⠓⠀⢀⣀⠀⣼ - ⢷⡀⠈⠙⠒⠒⠒⠋⠁⠈⣒⣤⣘⣧⣄⣀⠀⠀⢈⣻⠀⠀⠀⠀⠘⢥⣀⠀⠀⠀⠀⢹⡆⠀⢀⡴⠚⠉⣩⣷⠏ - ⠈⠳⣤⡀⠀⠀⠀⠀⠀⠉⠀⠀⠀⠈⠉⠛⠫⡍⠉⠁⠀⡴⠒⠤⣤⡀⠈⠉⠉⠙⠛⠋⠁⠀⠺⠤⢖⣫⠟⠃⠀ - ⠀⠀⠈⠙⠳⢦⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠓⠒⠒⠃⠀⠀⠀⠀⠀⢀⣀⣤⠴⠞⠋⠁⠀⠀⠀ - ⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠛⠛⠛⠛⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠛⠛⠛⠛⠛⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀`); + // warning(` + // ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⠴⠶⠦⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ + // ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣴⡯⠤⠴⠶⠶⠶⠿⠷⠶⠶⠦⠤⣴⠚⠛⠒⠶⣤⡀⠀⠀⠀⠀⠀⠀⠀ + // ⠀⠀⠀⠀⢀⣀⣠⣄⣤⠶⢚⣯⠭⠤⠶⠤⢤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⢦⣀⡀⠀⠈⢹⣆⠀⠀⠀⠀⠀⠀ + // ⠀⢀⡴⠞⠉⠀⠀⢀⡟⠀⢯⣄⣀⣀⣀⣀⣠⠿⠀⠀⢀⡤⠤⠒⠒⠒⠶⢤⡀⠈⠉⠉⣉⣭⣭⣗⣦⣄⡀⠀⠀ + // ⠀⣟⣀⣀⣠⠴⠞⠉⠀⡠⠤⠶⠾⣍⡭⠥⠤⠤⣀⠀⠘⢧⣀⠀⠀⠀⠀⣀⣽⣀⣀⣈⣧⡀⠀⠀⠈⠙⢿⣦⡀ + // ⣰⠋⠁⠀⠀⣀⣀⡀⠀⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⡹⠛⠉⠀⠀⠈⠉⠻⣗⠲⠦⠤⠾⠋⢷ + // ⡏⠀⣴⠋⠉⠁⠈⠉⣳⠀⠀⠀⢀⣠⠤⠶⠦⠤⣄⡀⠀⠀⠀⠀⠀⣀⠤⠴⠶⠦⣤⡀⠀⠀⠈⠓⠀⢀⣀⠀⣼ + // ⢷⡀⠈⠙⠒⠒⠒⠋⠁⠈⣒⣤⣘⣧⣄⣀⠀⠀⢈⣻⠀⠀⠀⠀⠘⢥⣀⠀⠀⠀⠀⢹⡆⠀⢀⡴⠚⠉⣩⣷⠏ + // ⠈⠳⣤⡀⠀⠀⠀⠀⠀⠉⠀⠀⠀⠈⠉⠛⠫⡍⠉⠁⠀⡴⠒⠤⣤⡀⠈⠉⠉⠙⠛⠋⠁⠀⠺⠤⢖⣫⠟⠃⠀ + // ⠀⠀⠈⠙⠳⢦⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠓⠒⠒⠃⠀⠀⠀⠀⠀⢀⣀⣤⠴⠞⠋⠁⠀⠀⠀ + // ⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠛⠛⠛⠛⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠛⠛⠛⠛⠛⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀`); for(var i=0;i " + message,4); + logger.debug(" " + message); } function help() { diff --git a/sync-rest-fetch.js b/sync-rest-fetch.js index ca9ed34..fea8188 100644 --- a/sync-rest-fetch.js +++ b/sync-rest-fetch.js @@ -18,7 +18,7 @@ let cookieJar = []; let domain; function consolelog(message, level) { - dbg.message(":" + message,level); + logger.debug(":" + message,level); } function debug(message) { diff --git a/themes.js b/themes.js index f0a7a48..628cb4e 100644 --- a/themes.js +++ b/themes.js @@ -11,7 +11,7 @@ var prettyprint = false; var url; function debug(message) { - dbg.message(" " + message,4); + logger.debug(" " + message); } function help() { diff --git a/users.js b/users.js index 911e012..819e38a 100644 --- a/users.js +++ b/users.js @@ -19,7 +19,7 @@ function checkForErrors(inBody) } function debug(message){ - dbg.message(" " + message,4); + logger.debug(" " + message); } diff --git a/wmiocli.js b/wmiocli.js index b67fd15..1ba25cd 100644 --- a/wmiocli.js +++ b/wmiocli.js @@ -21,10 +21,10 @@ var experimental = require('./experimental.js'); var hideExperimental = true; returnStart = 0; returnCount = 1000; -const { setLogLevel } = require('./debug.js'); -const { isTypedArray } = require('util/types'); +log4js = require("log4js"); +logger = log4js.getLogger(); +logger.level="off"; -dbg = require('./debug.js'); prettyprint = false; proxy = undefined; caCertFile = undefined; @@ -99,19 +99,19 @@ function checkOptions() { else { switch (levelInput) { case "OFF": - dbg.setLogLevel(0); + logger.level= "off"; break; case "ERROR": - dbg.setLogLevel(1); + logger.level = "error"; break; case "WARN": - dbg.setLogLevel(2); + logger.level = "warn"; break; case "INFO": - dbg.setLogLevel(3); + logger.level = "info"; break; case "DEBUG": - dbg.setLogLevel(4); + logger.level = "debug"; break; default: console.log("-level incorrectly set, should be one of: OFF, ERROR, WARN, INFO, DEBUG"); @@ -147,8 +147,9 @@ function checkOptions() { } function debug(message) { - dbg.message("
" + message, 4); + logger.debug(message); } + const program = new Command(); program diff --git a/workflow.js b/workflow.js index 79f8066..20b14cb 100644 --- a/workflow.js +++ b/workflow.js @@ -10,7 +10,7 @@ var domainName, username, password, timeout, prettyprint; var url; function debug(message) { - dbg.message(" " + message,4); + logger.debug(" " + message); } function help() {