Skip to content

Commit

Permalink
Merge pull request #4163 from sap-labs-france/master-qa
Browse files Browse the repository at this point in the history
Version 2.7.6 - logs less verbose
  • Loading branch information
Claude ROSSI authored Mar 28, 2023
2 parents 6bc2945 + b5dbfa3 commit 3bf5d43
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,20 +491,24 @@ export default class RemotePushNotificationTask implements NotificationTask {
// Do it
startTime = Logging.traceNotificationStart();
if (!user?.mobileData?.mobileToken) {
await Logging.logDebug({
tenantID: tenant.id,
siteID: data?.siteID,
siteAreaID: data?.siteAreaID,
companyID: data?.companyID,
chargingStationID: data?.chargeBoxID,
action: ServerAction.REMOTE_PUSH_NOTIFICATION,
module: MODULE_NAME, method: 'sendRemotePushNotificationToUsers',
message: `'${notificationType}': No mobile token found for this User`,
actionOnUser: user.id,
});
// await Logging.logDebug({
// tenantID: tenant.id,
// siteID: data?.siteID,
// siteAreaID: data?.siteAreaID,
// companyID: data?.companyID,
// chargingStationID: data?.chargeBoxID,
// action: ServerAction.REMOTE_PUSH_NOTIFICATION,
// module: MODULE_NAME, method: 'sendRemotePushNotificationToUsers',
// message: `'${notificationType}': No mobile token found for this User`,
// actionOnUser: user.id,
// });
// Send nothing
return Promise.resolve();
}
if (!user?.mobileData?.mobileVersion) {
// Stop sending notifications to old version of the mobile app
return Promise.resolve();
}
// Create message
message = this.createMessage(tenant, notificationType, title, body, data, severity);
// Get the right firebase apps
Expand All @@ -524,47 +528,47 @@ export default class RemotePushNotificationTask implements NotificationTask {
);
// Error
if (response.failureCount > 0) {
void Logging.logError({
Logging.logError({
tenantID: tenant.id,
siteID: data?.siteID,
siteAreaID: data?.siteAreaID,
companyID: data?.companyID,
chargingStationID: data?.chargeBoxID,
action: ServerAction.REMOTE_PUSH_NOTIFICATION,
module: MODULE_NAME, method: 'sendRemotePushNotificationToUsers',
message: `Error when sending Notification: '${notificationType}' - Error code: '${response.results[0]?.error?.code}'`,
message: `Notification: '${notificationType}' - Error code: '${response.results[0]?.error?.code}'`,
actionOnUser: user.id,
detailedMessages: { response }
});
detailedMessages: { response, mobileData: user.mobileData }
}).catch((error) => Logging.logPromiseError(error));
// Success
} else {
// Stop sending notification
notificationSent = true;
void Logging.logDebug({
tenantID: tenant.id,
siteID: data?.siteID,
siteAreaID: data?.siteAreaID,
companyID: data?.companyID,
chargingStationID: data?.chargeBoxID,
action: ServerAction.REMOTE_PUSH_NOTIFICATION,
module: MODULE_NAME, method: 'sendRemotePushNotificationToUsers',
message: `Notification Sent: '${notificationType}' - '${title}'`,
actionOnUser: user.id,
});
// Logging.logDebug({
// tenantID: tenant.id,
// siteID: data?.siteID,
// siteAreaID: data?.siteAreaID,
// companyID: data?.companyID,
// chargingStationID: data?.chargeBoxID,
// action: ServerAction.REMOTE_PUSH_NOTIFICATION,
// module: MODULE_NAME, method: 'sendRemotePushNotificationToUsers',
// message: `Notification Sent: '${notificationType}' - '${title}'`,
// actionOnUser: user.id,
// }).catch((error) => Logging.logPromiseError(error));
}
} catch (error) {
void Logging.logError({
Logging.logError({
tenantID: tenant.id,
siteID: data?.siteID,
siteAreaID: data?.siteAreaID,
companyID: data?.companyID,
chargingStationID: data?.chargeBoxID,
action: ServerAction.REMOTE_PUSH_NOTIFICATION,
module: MODULE_NAME, method: 'sendRemotePushNotificationToUsers',
message: `Error when sending Notification: '${notificationType}' - '${error.message as string}'`,
message: `Notification: '${notificationType}' - '${error.message as string}'`,
actionOnUser: user.id,
detailedMessages: { error: error.stack }
});
}).catch((error2) => Logging.logPromiseError(error2));
}
}
} finally {
Expand Down
49 changes: 29 additions & 20 deletions src/server/ocpp/utils/OCPPUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,10 @@ export default class OCPPUtils {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationConnectorWithTemplate',
message: `Template for Connector ID '${connector.connectorId}' cannot be applied on manual configured charging station`,
detailedMessages: { chargingStation, connector }
detailedMessages: {
chargingStationData: LoggingHelper.shrinkChargingStationProperties(chargingStation),
connector
}
});
return false;
}
Expand Down Expand Up @@ -880,7 +883,6 @@ export default class OCPPUtils {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationConnectorWithTemplate',
message: `Template ID '${chargingStationTemplate.id}' has been applied on Connector ID '${connector.connectorId}' with success`,
detailedMessages: { chargingStationTemplate, chargingStation }
});
return true;
}
Expand All @@ -891,7 +893,10 @@ export default class OCPPUtils {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationConnectorWithTemplate',
message: `No Connector found in Template ID '${chargingStationTemplate.id}'`,
detailedMessages: { chargingStationTemplate, chargingStation }
detailedMessages: {
templateData: LoggingHelper.shrinkTemplateProperties(chargingStationTemplate),
chargingStationData: LoggingHelper.shrinkChargingStationProperties(chargingStation)
}
});
return false;
}
Expand All @@ -902,7 +907,10 @@ export default class OCPPUtils {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationConnectorWithTemplate',
message: 'No Template has been found for this Charging Station',
detailedMessages: { chargingStation, connector }
detailedMessages: {
chargingStationData: LoggingHelper.shrinkChargingStationProperties(chargingStation),
connector
}
});
return false;
}
Expand Down Expand Up @@ -1521,7 +1529,9 @@ export default class OCPPUtils {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationWithTemplate',
message: 'Template cannot be applied on manual configured charging station',
detailedMessages: { chargingStation }
detailedMessages: {
chargingStationData: LoggingHelper.shrinkChargingStationProperties(chargingStation)
}
});
return templateUpdateResult;
}
Expand Down Expand Up @@ -1563,17 +1573,6 @@ export default class OCPPUtils {
templateData: LoggingHelper.shrinkTemplateProperties(chargingStationTemplate),
}
});
} else {
await Logging.logDebug({
...LoggingHelper.getChargingStationProperties(chargingStation),
tenantID: tenant.id,
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationWithTemplate',
message: `Template ID '${chargingStationTemplate.id}' has already been applied`,
detailedMessages: {
templateData: LoggingHelper.shrinkTemplateProperties(chargingStationTemplate)
}
});
}
// Master/Slave: always override the charge point
if (chargingStationTemplate.template.technical.masterSlave) {
Expand Down Expand Up @@ -1648,7 +1647,9 @@ export default class OCPPUtils {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationWithTemplate',
message: `Template contains power limitation key '${parameter}' in OCPP parameters, skipping. Remove it from template!`,
detailedMessages: { chargingStationTemplate }
detailedMessages: {
templateData: LoggingHelper.shrinkTemplateProperties(chargingStationTemplate)
}
});
continue;
}
Expand All @@ -1659,7 +1660,9 @@ export default class OCPPUtils {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationWithTemplate',
message: `Template contains heartbeat interval key '${parameter}' in OCPP parameters, skipping. Remove it from template`,
detailedMessages: { chargingStationTemplate }
detailedMessages: {
templateData: LoggingHelper.shrinkTemplateProperties(chargingStationTemplate)
}
});
continue;
}
Expand All @@ -1678,7 +1681,10 @@ export default class OCPPUtils {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationWithTemplateOcppParams',
message: `Cannot find a matching section named '${ocppProperty}' in Template ID '${chargingStationTemplate.id}'`,
detailedMessages: { chargingStationTemplate, chargingStation }
detailedMessages: {
templateData: LoggingHelper.shrinkTemplateProperties(chargingStationTemplate),
chargingStationData: LoggingHelper.shrinkChargingStationProperties(chargingStation)
}
});
}
}
Expand Down Expand Up @@ -1725,7 +1731,10 @@ export default class OCPPUtils {
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationWithTemplateCapabilities',
message: `Cannot find a matching section named 'capabilities' in Template ID '${chargingStationTemplate.id}'`,
detailedMessages: { chargingStationTemplate, chargingStation }
detailedMessages: {
templateData: LoggingHelper.shrinkTemplateProperties(chargingStationTemplate),
chargingStationData: LoggingHelper.shrinkChargingStationProperties(chargingStation)
}
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/rest/v1/service/PricingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export default class PricingService {
siteID = siteArea.siteID;
break;
case PricingEntity.CHARGING_STATION:
chargingStation = await UtilsService.checkAndGetChargingStationAuthorization(req.tenant, req.user, entityID, Action.READ, action);
chargingStation = await UtilsService.checkAndGetChargingStationAuthorization(req.tenant, req.user, entityID, Action.READ, action, null, { includeDeleted: true });
siteID = chargingStation.siteID;
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/server/rest/v1/service/UtilsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class UtilsService {
UtilsService.assertObjectExists(action, chargingStation, `ChargingStation ID '${chargingStationID}' does not exist`,
MODULE_NAME, 'checkAndGetChargingStationAuthorization', userToken);
// Check deleted
if (chargingStation?.deleted) {
if (!additionalFilters?.includeDeleted && chargingStation?.deleted) {
throw new AppError({
...LoggingHelper.getChargingStationProperties(chargingStation),
errorCode: StatusCodes.NOT_FOUND,
Expand Down

0 comments on commit 3bf5d43

Please sign in to comment.