Log detail messages with Json doc only
MODIFY
src/client/ocpp/json/JsonRestChargingStationClient.ts
src/client/ocpp/json/JsonRestChargingStationClient.ts
@@ -184,7 +184,7 @@ export default class JsonRestChargingStationClient extends ChargingStationClient
action: ServerAction.WS_REST_CLIENT_ERROR_RESPONSE,
module: MODULE_NAME, method: 'onMessage',
message: `${commandPayload.toString()}`,
- detailedMessages: [messageType, messageId, commandName, commandPayload, errorDetails]
+ detailedMessages: { messageType, messageId, commandName, commandPayload, errorDetails }
});
// Resolve with error message
this.requests[messageId].reject({ status: OCPPStatus.REJECTED, error: [messageType, messageId, commandName, commandPayload, errorDetails] });
@@ -202,7 +202,7 @@ export default class JsonRestChargingStationClient extends ChargingStationClient
action: ServerAction.WS_REST_CLIENT_ERROR_RESPONSE,
module: MODULE_NAME, method: 'onMessage',
message: 'Received unknown message',
- detailedMessages: [messageType, messageId, commandName, commandPayload, errorDetails]
+ detailedMessages: { messageType, messageId, commandName, commandPayload, errorDetails }
});
}
} catch (error) {

MODIFY
src/client/ocpp/soap/SoapChargingStationClient.ts
src/client/ocpp/soap/SoapChargingStationClient.ts
@@ -90,18 +90,13 @@ export default class SoapChargingStationClient extends ChargingStationClient {
'remoteStopTransactionRequest': params
});
if (error) {
- // Log
await Logging.logError({
tenantID: this.tenantID,
action: ServerAction.CHARGING_STATION_REMOTE_STOP_TRANSACTION,
source: this.chargingStation.id,
module: MODULE_NAME, method: 'remoteStopTransaction',
message: `Error when trying to stop the transaction ID ${params.transactionId}: ${error.toString()}`,
- detailedMessages: [
- { 'stack': error.stack },
- { result },
- { envelope }
- ]
+ detailedMessages: { 'error': error.stack, result, envelope }
});
throw error;
}
@@ -130,11 +125,7 @@ export default class SoapChargingStationClient extends ChargingStationClient {
source: this.chargingStation.id,
module: MODULE_NAME, method: 'remoteStartTransaction',
message: `Error when trying to start a transaction: ${error.toString()}`,
- detailedMessages: [
- { 'stack': error.stack },
- { result },
- { envelope }
- ]
+ detailedMessages: { 'error': error.stack , result, envelope },
});
throw error;
}
@@ -165,11 +156,7 @@ export default class SoapChargingStationClient extends ChargingStationClient {
source: this.chargingStation.id,
module: MODULE_NAME, method: 'unlockConnector',
message: `Error when trying to unlock the connector '${params.connectorId}': ${error.toString()}`,
- detailedMessages: [
- { 'stack': error.stack },
- { result },
- { envelope }
- ]
+ detailedMessages: { 'error': error.stack , result, envelope }
});
throw error;
}
@@ -199,11 +186,7 @@ export default class SoapChargingStationClient extends ChargingStationClient {
source: this.chargingStation.id,
module: MODULE_NAME, method: 'reset',
message: `Error when trying to reboot: ${error.toString()}`,
- detailedMessages: [
- { 'stack': error.stack },
- { result },
- { envelope }
- ]
+ detailedMessages: { 'error': error.stack , result, envelope }
});
return error;
}
@@ -231,11 +214,7 @@ export default class SoapChargingStationClient extends ChargingStationClient {
source: this.chargingStation.id,
module: MODULE_NAME, method: 'clearCache',
message: `Error when trying to clear the cache: ${error.toString()}`,
- detailedMessages: [
- { 'stack': error.stack },
- { result },
- { envelope }
- ]
+ detailedMessages: { 'error': error.stack , result, envelope }
});
throw error;
}
@@ -272,11 +251,7 @@ export default class SoapChargingStationClient extends ChargingStationClient {
source: this.chargingStation.id,
module: MODULE_NAME, method: 'getConfiguration',
message: `Error when trying to get the configuration: ${error.toString()}`,
- detailedMessages: [
- { 'stack': error.stack },
- { result },
- { envelope }
- ]
+ detailedMessages: { 'error': error.stack , result, envelope }
});
throw error;
}
@@ -312,11 +287,7 @@ export default class SoapChargingStationClient extends ChargingStationClient {
module: MODULE_NAME, method: 'changeConfiguration',
action: ServerAction.CHARGING_STATION_CHANGE_CONFIGURATION,
message: `Error when trying to change the configuration parameter '${key}' with value '${value}': ${error.toString()}`,
- detailedMessages: [
- { 'stack': error.stack },
- { result },
- { envelope }
- ]
+ detailedMessages: { 'error': error.stack , result, envelope }
});
throw error;
}

MODIFY
src/notification/email/EMailNotificationTask.ts
src/notification/email/EMailNotificationTask.ts
@@ -233,20 +233,14 @@ export default class EMailNotificationTask implements NotificationTask {
module: MODULE_NAME, method: 'sendEmail',
actionOnUser: user,
message: `Email Sent: '${rfc2047.decode(messageSent.header.subject)}'`,
- detailedMessages: [
- {
- email: {
+ detailedMessages: {
from: rfc2047.decode(messageSent.header.from.toString()),
to: rfc2047.decode(messageSent.header.to.toString()),
- subject: rfc2047.decode(messageSent.header.subject)
- },
- }, {
+ subject: rfc2047.decode(messageSent.header.subject),
content: email.html
}
- ]
});
} catch (error) {
- // Log
try {
await Logging.logError({
tenantID: tenant.id ? tenant.id : Constants.DEFAULT_TENANT,
@@ -255,17 +249,13 @@ export default class EMailNotificationTask implements NotificationTask {
module: MODULE_NAME, method: 'sendEmail',
message: `Error Sending Email (${rfc2047.decode(messageToSend.header.from.toString())}): '${rfc2047.decode(messageToSend.header.subject)}'`,
actionOnUser: user,
- detailedMessages: [
- {
- email: {
+ detailedMessages: {
from: rfc2047.decode(messageToSend.header.from.toString()),
to: rfc2047.decode(messageToSend.header.to.toString()),
- subject: rfc2047.decode(messageToSend.header.subject)
- },
- },
- { error: error.stack },
- { content: email.html }
- ]
+ subject: rfc2047.decode(messageToSend.header.subject),
+ error: error.stack,
+ content: email.html
+ }
});
// For Unit Tests only: Tenant is deleted and email is not known thus this Logging statement is always failing with an invalid Tenant
// eslint-disable-next-line no-empty

MODIFY
src/notification/remote-push-notification/RemotePushNotificationTask.ts
src/notification/remote-push-notification/RemotePushNotificationTask.ts
@@ -458,7 +458,7 @@ export default class RemotePushNotificationTask implements NotificationTask {
module: MODULE_NAME, method: 'sendRemotePushNotificationToUsers',
message: `'${notificationType}': No mobile token found for this User`,
actionOnUser: user.id,
- detailedMessages: [title, body]
+ detailedMessages: { title, body }
});
// Send nothing
return Promise.resolve();
@@ -472,24 +472,24 @@ export default class RemotePushNotificationTask implements NotificationTask {
{ priority: 'high', timeToLive: 60 * 60 * 24 }
).then((response) => {
// Response is a message ID string.
- Logging.logDebug({
+ void Logging.logDebug({
tenantID: tenant.id,
source: (data && Utils.objectHasProperty(data, 'chargeBoxID') ? data['chargeBoxID'] : null),
action: ServerAction.REMOTE_PUSH_NOTIFICATION,
module: MODULE_NAME, method: 'sendRemotePushNotificationToUsers',
message: `Notification Sent: '${notificationType}' - '${title}'`,
actionOnUser: user.id,
- detailedMessages: [message, response]
+ detailedMessages: { message, response }
});
}).catch((error: Error) => {
- Logging.logError({
+ void Logging.logError({
tenantID: tenant.id,
source: (data && Utils.objectHasProperty(data, 'chargeBoxID') ? data['chargeBoxID'] : null),
action: ServerAction.REMOTE_PUSH_NOTIFICATION,
module: MODULE_NAME, method: 'sendRemotePushNotificationToUsers',
message: `Error when sending Notification: '${notificationType}' - '${error.message}'`,
actionOnUser: user.id,
- detailedMessages: { error: error.stack }
+ detailedMessages: { error: error.stack, message }
});
});
}

MODIFY
src/server/ocpp/json/WSConnection.ts
src/server/ocpp/json/WSConnection.ts
@@ -183,7 +183,7 @@ export default abstract class WSConnection {
method: 'onMessage',
action: commandName,
message: `Error occurred '${commandName}' with message content '${JSON.stringify(commandPayload)}'`,
- detailedMessages: [messageType, messageId, commandName, commandPayload, errorDetails]
+ detailedMessages: { messageType, messageId, commandName, commandPayload, errorDetails }
});
if (!this.requests[messageId]) {
// Error

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -740,7 +740,7 @@ export default class OCPPService {
module: MODULE_NAME, method: 'processConnectorStatusNotification',
action: ServerAction.STATUS_NOTIFICATION,
message: `${Utils.buildConnectorInfo(statusNotification.connectorId, connector.currentTransactionID)} Status '${this.buildConnectorStatusDescription(connector)}' has been saved`,
- detailedMessages: [statusNotification, connector]
+ detailedMessages: { statusNotification, connector }
});
// Notify Users
await this.notifyStatusNotification(tenant, chargingStation, connector);

MODIFY
src/utils/Logging.ts
src/utils/Logging.ts
@@ -677,10 +677,10 @@ export default class Logging {
module: exception.params.module, method: exception.params.method,
action: action,
message: exception.message,
- detailedMessages: [{
- stack: exception.stack,
+ detailedMessages: {
+ error: exception.stack,
...detailedMessages
- }]
+ }
});
}
@@ -696,10 +696,10 @@ export default class Logging {
module: module, method: method,
action: action,
message: error.message,
- detailedMessages: [{
+ detailedMessages: {
details: error.params.detailedMessages,
- stack: error.stack
- }]
+ error: error.stack
+ }
};
}
return {
@@ -710,10 +710,10 @@ export default class Logging {
module: module, method: method,
action: action,
message: error.message,
- detailedMessages: [{
+ detailedMessages: {
details: error.detailedMessages,
stack: error.stack
- }]
+ }
};
}

Log detail messages with Json doc only