Skip to content

Commit

Permalink
change 'normal' by 'info' in log type
Browse files Browse the repository at this point in the history
  • Loading branch information
cviolbarbosa committed Nov 26, 2024
1 parent 6ea8a72 commit b3c0d55
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function processAssignmentEvents(msg) {
.then(() => agentComm.sendReleaseFromWorkProcessRequest(payload['agent_id'], payload['work_process_id']))
.then(() => {
if (fallbackMission) {
logData.addLog('agent', {'agent_id': payload.agent_id}, 'normal', `fallback mission: ${fallbackMission}`)
logData.addLog('agent', {'agent_id': payload.agent_id}, 'info', `fallback mission: ${fallbackMission}`)
return databaseServices.assignments.get_byId(payload['id'])
.then((assignment) => {
const data = {...wp.data,
Expand All @@ -111,7 +111,7 @@ function processAssignmentEvents(msg) {
work_process_type_name: fallbackMission,
status: MISSION_STATUS.DISPATCHED
})
.then((wpId) => logData.addLog('agent', {'agent_id': assignment.agent_id}, 'normal', `fallback mission dispatched`))
.then((wpId) => logData.addLog('agent', {'agent_id': assignment.agent_id}, 'info', `fallback mission dispatched`))
})
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function processInstantActionEvents(msg) {
agentComm.sendCustomInstantActionToAgent(agentId, payload['command']);
}
const log = { agent_id: agentId, agent_uuid: agentUuid, sender: payload.sender};
logData.addLog('agent', log, 'normal', `send custom instant action to agent`);
logData.addLog('agent', log, 'info', `send custom instant action to agent`);

break;

Expand Down
6 changes: 3 additions & 3 deletions helyos_server/src/event_handlers/database_event_subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function handleDatabaseMessages(client) {
break;

case 'agent_deletion':
logData.addLog('agent', payload, 'normal', `agent deleted`);
logData.addLog('agent', payload, 'info', `agent deleted`);

try {
await removeAgentRbmqAccount(payload);
Expand All @@ -111,14 +111,14 @@ function handleDatabaseMessages(client) {
break;

case 'change_agent_status':
logData.addLog('agent', payload, 'normal', `agent changed: "${payload.connection_status}"-"${payload.status}"`);
logData.addLog('agent', payload, 'info', `agent changed: "${payload.connection_status}"-"${payload.status}"`);
break;


case 'new_rabbitmq_account':
try {
await createAgentRbmqAccount({id: payload.agent_id}, payload['username'], payload['password']);
logData.addLog('agent', {id: payload.agent_id}, 'normal', `create/update rabbitmq account`);
logData.addLog('agent', {id: payload.agent_id}, 'info', `create/update rabbitmq account`);
} catch (error) {
logData.addLog('agent', payload, 'error', `Create RabbitMQ account: ${error.message}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const waitForServicesResults = () => {
logMsg = `job not ready: elpsed time (sec) - ${(now - serviceReq.dispatched_at)/1000}` ;
}

logData.addLog('microservice', serviceReq, 'normal', logMsg);
logData.addLog('microservice', serviceReq, 'info', logMsg);
}


Expand All @@ -45,7 +45,7 @@ const waitForServicesResults = () => {
}
} else {
return extServCommunication.saveServiceResponse(serviceReq.id, servResponse, SERVICE_STATUS.FAILED) // default satus is failed. if service is ok, it will be updated.
.then( status => logData.addLog('microservice', serviceReq, 'normal', `job is ${status}`));
.then( status => logData.addLog('microservice', serviceReq, 'info', `job is ${status}`));
}
})
.catch(e => {
Expand Down Expand Up @@ -77,7 +77,7 @@ const sendRequestToCancelServices = () => {
.then( accessData => webServices.cancelService(accessData.url, accessData.apiKey, serviceReq.service_queue_id))
.then((servResponse) => {
servResponse = {status:'canceled',result:{}};
logData.addLog('microservice', serviceReq, 'normal', `Canceling signal sent to microservice: job is ${servResponse.status}`);
logData.addLog('microservice', serviceReq, 'info', `Canceling signal sent to microservice: job is ${servResponse.status}`);
return databaseServices.service_requests.updateByConditions({id: serviceReq.id, processed: false, status: SERVICE_STATUS.CANCELED},
{ fetched: true,
processed: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async function processAgentCheckIn(uuid, data, msgProps, registeredAgent) {
agentUpdate['message_channel'] = replyTo || uuid;

if ('public_key' in checkinData){
logData.addLog('agent', {uuid}, 'normal', `agent public key updated`);
logData.addLog('agent', {uuid}, 'info', `agent public key updated`);
agentUpdate['public_key'] = checkinData.public_key;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async function agentAutoUpdate(objMsg, uuid, bufferPeriod=0) {
async function connectFollowersToLeader (leaderUUID, followerUUIDs) {
databaseServices.connectAgents(leaderUUID, followerUUIDs)
.then((newConnectionIds) => {
logData.addLog('agent', {uuid: leaderUUID}, 'normal', `Followers connected to this agent # : ${newConnectionIds.length? newConnectionIds:'None'}` );
logData.addLog('agent', {uuid: leaderUUID}, 'info', `Followers connected to this agent # : ${newConnectionIds.length? newConnectionIds:'None'}` );
// Allow follower agents to be updated by the leader agent user account.
const followerPatchs = followerUUIDs.map( uuid => ({uuid, rbmq_username: leaderUUID}));
return databaseServices.agents.updateMany(followerPatchs,'uuid');
Expand Down
6 changes: 3 additions & 3 deletions helyos_server/src/event_handlers/rabbitmq_event_subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ function handleBrokerMessages(channelOrQueue, message) {
}
}

logData.addLog('agent', checkinData, 'normal', `agent trying to check in ${message.content.toString()}`);
logData.addLog('agent', checkinData, 'info', `agent trying to check in ${message.content.toString()}`);
const replyExchange = exchange === AGENT_MQTT_EXCHANGE? AGENT_MQTT_EXCHANGE : AGENTS_DL_EXCHANGE;
return agentCheckIn(uuid, objMsg.obj, msgProps, registeredAgent, replyExchange)
.then(( ) => logData.addLog('agent', objMsg.obj, 'normal', `agent checked in ${message.content.toString()}`))
.then(( ) => logData.addLog('agent', objMsg.obj, 'info', `agent checked in ${message.content.toString()}`))
.catch( err => {
console.log('checkin:', err);
logData.addLog('agent', objMsg.obj, 'error', `agent failed to check in ${err.message} ${JSON.stringify(err, Object.getOwnPropertyNames(err))}`);
Expand Down Expand Up @@ -291,7 +291,7 @@ function handleBrokerMessages(channelOrQueue, message) {
if (objMsg.obj.body){
const newWProc = {status: MISSION_STATUS.DISPATCHED};
databaseServices.work_processes.insert({...objMsg.obj.body, ...newWProc})
.then((wpId) => logData.addLog('agent', {...objMsg.obj.body, work_process_id: wpId}, 'normal', `agent created a mission: ${wpId}`))
.then((wpId) => logData.addLog('agent', {...objMsg.obj.body, work_process_id: wpId}, 'info', `agent created a mission: ${wpId}`))
.catch(e => logData.addLog('agent', objMsg.obj, 'error', `agent create mission=${e}`));
} else {
logData.addLog('agent', objMsg.obj, 'error', `agent create mission: input data not found`);
Expand Down
12 changes: 6 additions & 6 deletions helyos_server/src/modules/microservice_orchestration.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ async function prepareServicesPipelineForWorkProcess(partialWorkProcess) {

// Waiting agents to be "FREE"
try {
logData.addLog('agent', logMetadata, 'normal', `waiting agent to be free`);
logData.addLog('agent', logMetadata, 'info', `waiting agent to be free`);
agentResponse = await agentComm.waitAgentStatusForWorkProcess(agentsListIds, 'FREE', null, WAIT_AGENT_STATUS_PERIOD)
.catch( e => {throw e});
agentsListIds.forEach(agentId => databaseServices.agents.update_byId(agentId, {work_process_id: null}));
logData.addLog('agent', logMetadata, 'normal', `agent is free`);
logData.addLog('agent', logMetadata, 'info', `agent is free`);

} catch (error) {
logData.addLog('agent', logMetadata, 'error', `expected free=${error}`);
Expand All @@ -290,23 +290,23 @@ async function prepareServicesPipelineForWorkProcess(partialWorkProcess) {
await agentComm.sendGetReadyForWorkProcessRequest(agentsListIds, workProcess.id, workProcess.operation_types_required);
missionAgents.forEach( agent => {
logMetadata['uuid'] = agent.uuid;
logData.addLog('agent', logMetadata, 'normal', `requesting agent to be ready`);
logData.addLog('agent', logMetadata, 'info', `requesting agent to be ready`);
});

// Waiting agents to acknowledge to be "READY"
const waitReadyAcknListIds = missionAgentsToAckn.map( t => t.id);
try {
missionAgentsToAckn.forEach( agent => {
logMetadata['uuid'] = agent.uuid;
logData.addLog('agent', logMetadata, 'normal', `waiting agent to be ready`);
logData.addLog('agent', logMetadata, 'info', `waiting agent to be ready`);
});
agentResponse = await agentComm.waitAgentStatusForWorkProcess(waitReadyAcknListIds, 'READY', workProcess.id,WAIT_AGENT_STATUS_PERIOD)
.catch( e => {throw e});
agentsListIds.forEach(agentId => databaseServices.agents.update_byId(agentId, {work_process_id: workProcess.id}));

missionAgentsToAckn.forEach( agent => {
logMetadata['uuid'] = agent.uuid;
logData.addLog('agent', logMetadata, 'normal', `agent is ready`);
logData.addLog('agent', logMetadata, 'info', `agent is ready`);
});

} catch (error) {
Expand Down Expand Up @@ -472,7 +472,7 @@ async function activateNextServicesInPipeline(partialServiceRequest) {
return Promise.resolve(0);
}

logData.addLog('helyos_core', null, 'normal', `activate Next Services In Pipeline, workprocess status is ${workProcessStatus.status}`);
logData.addLog('helyos_core', null, 'info', `activate Next Services In Pipeline, workprocess status is ${workProcessStatus.status}`);

const serviceRequest = await databaseServices.service_requests.get_byId(partialServiceRequest.id);
const nextRequests = await databaseServices.service_requests.list_in('request_uid', serviceRequest.next_request_to_dispatch_uids);
Expand Down

0 comments on commit b3c0d55

Please sign in to comment.