Adding changes to add site id logging for site admin
MODIFY
src/authorization/Authorizations.ts
src/authorization/Authorizations.ts
@@ -904,6 +904,7 @@ export default class Authorizations {
// Check Tag ID
if (remoteAuthorization.tagId === tag.ocpiToken?.uid) {
await Logging.logDebug({
+ siteID: chargingStation.siteID,
source: chargingStation.id,
tenantID: tenant.id, action,
message: `${Utils.buildConnectorInfo(connector.connectorId, transaction?.id)} Valid Remote Authorization found for Tag ID '${tag.ocpiToken.uid}'`,

MODIFY
src/client/ocpi/EmspOCPIClient.ts
src/client/ocpi/EmspOCPIClient.ts
@@ -495,6 +495,7 @@ export default class EmspOCPIClient extends OCPIClient {
await Logging.logDebug({
tenantID: this.tenant.id,
action: ServerAction.OCPI_START_SESSION,
+ siteID: chargingStation.siteID,
source: chargingStation.id,
message: `${Utils.buildConnectorInfo(connectorID)} OCPI Remote Start session response status '${response.status}'`,
module: MODULE_NAME, method: 'remoteStartSession',
@@ -553,6 +554,7 @@ export default class EmspOCPIClient extends OCPIClient {
await Logging.logDebug({
tenantID: this.tenant.id,
action: ServerAction.OCPI_STOP_SESSION,
+ siteID: transaction.siteID,
source: transaction.chargeBoxID,
message: `${Utils.buildConnectorInfo(transaction.connectorId, transaction.id)} OCPI Remote Stop response status '${response.status}'`,
module: MODULE_NAME, method: 'remoteStopSession',

MODIFY
src/client/oicp/CpoOICPClient.ts
src/client/oicp/CpoOICPClient.ts
@@ -83,6 +83,7 @@ export default class CpoOICPClient extends OICPClient {
await Logging.logDebug({
tenantID: this.tenant.id,
user: transaction.user,
+ siteID: transaction.siteID,
source: transaction.chargeBoxID,
action: ServerAction.OICP_PUSH_SESSIONS,
message: `Start OICP Session ID '${transaction.id}'`,

MODIFY
src/integration/charging-station-vendor/ChargingStationVendorIntegration.ts
src/integration/charging-station-vendor/ChargingStationVendorIntegration.ts
@@ -89,6 +89,7 @@ export default abstract class ChargingStationVendorIntegration {
try {
await Logging.logDebug({
tenantID: tenant.id,
+ siteID: chargingStation.siteID,
source: chargingStation.id,
action: ServerAction.CHARGING_STATION_LIMIT_POWER,
message: `Set Power limitation via OCPP on ${chargePoint.ocppParamForPowerLimitation} key to ${ocppLimitAmpValue} value`,

MODIFY
src/notification/NotificationHandler.ts
src/notification/NotificationHandler.ts
@@ -1253,6 +1253,7 @@ export default class NotificationHandler {
// User
await Logging.logDebug({
tenantID: tenant.id,
+ siteID: (extraParams.chargingStation ? extraParams.chargingStation.siteID : null),
source: (extraParams.chargingStation ? extraParams.chargingStation.id : null),
module: MODULE_NAME, method: 'saveNotification',
action: sourceDescr,
@@ -1263,6 +1264,7 @@ export default class NotificationHandler {
// Admin
await Logging.logDebug({
tenantID: tenant.id,
+ siteID: (extraParams.chargingStation ? extraParams.chargingStation.siteID : null),
source: (extraParams.chargingStation ? extraParams.chargingStation.id : null),
module: MODULE_NAME, method: 'saveNotification',
action: sourceDescr,

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -160,6 +160,7 @@ export default class OCPPService {
// Log
await Logging.logDebug({
tenantID: tenant.id,
+ siteID: chargingStation.siteID,
source: chargingStation.id,
module: MODULE_NAME, method: 'handleHeartbeat',
action: ServerAction.HEARTBEAT,
@@ -231,6 +232,7 @@ export default class OCPPService {
if (Utils.isEmptyArray(normalizedMeterValues.values)) {
await Logging.logDebug({
tenantID: tenant.id,
+ siteID: chargingStation.siteID,
source: chargingStation.id,
module: MODULE_NAME, method: 'handleMeterValues',
action: ServerAction.METER_VALUES,
@@ -687,6 +689,7 @@ export default class OCPPService {
await OCPPUtils.clearAndDeleteChargingProfile(tenant, chargingProfile);
await Logging.logDebug({
tenantID: tenant.id,
+ siteID: transaction.siteID,
source: transaction.chargeBoxID,
action: ServerAction.CHARGING_PROFILE_DELETE,
message: `${Utils.buildConnectorInfo(transaction.connectorId, transaction.id)} TX Charging Profile with ID '${chargingProfile.id}'`,

MODIFY
src/server/ocpp/utils/OCPPUtils.ts
src/server/ocpp/utils/OCPPUtils.ts
@@ -1270,6 +1270,7 @@ export default class OCPPUtils {
public static async applyTemplateOcppParametersToChargingStation(tenant: Tenant, chargingStation: ChargingStation): Promise<OCPPChangeConfigurationCommandResult> {
await Logging.logDebug({
tenantID: tenant.id,
+ siteID: chargingStation.siteID,
source: chargingStation.id,
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'applyTemplateOcppParametersToChargingStation',
@@ -1586,6 +1587,7 @@ export default class OCPPUtils {
const ocppConfiguration = await OCPPUtils.requestChargingStationOcppParameters(tenant, chargingStation, {});
await Logging.logDebug({
tenantID: tenant.id,
+ siteID: chargingStation.siteID,
source: chargingStation.id,
action: ServerAction.CHARGING_STATION_CHANGE_CONFIGURATION,
module: MODULE_NAME, method: 'requestAndSaveChargingStationOcppParameters',
@@ -2126,6 +2128,7 @@ export default class OCPPUtils {
}
await Logging.logDebug({
tenantID: tenant.id,
+ siteID: chargingStation.siteID,
source: chargingStation.id,
action: ServerAction.UPDATE_CHARGING_STATION_WITH_TEMPLATE,
module: MODULE_NAME, method: 'enrichChargingStationWithTemplate',

MODIFY
src/server/oicp/oicp-services-impl/oicp-2.3.0/CPORemoteAuthorizationsEndpoint.ts
src/server/oicp/oicp-services-impl/oicp-2.3.0/CPORemoteAuthorizationsEndpoint.ts
@@ -109,6 +109,7 @@ export default class CPORemoteAuthorizationsEndpoint extends AbstractEndpoint {
// Current remote authorization fails due to valid remote authorization of different user
await Logging.logDebug({
tenantID: tenant.id,
+ siteID: chargingStation.siteID,
source: chargingStation.id,
action: ServerAction.OICP_AUTHORIZE_REMOTE_START,
message: `An existing remote authorization exists for Charging Station '${chargingStation.id}' and Connector ID ${connector.connectorId}`,

MODIFY
src/storage/mongodb/LoggingStorage.ts
src/storage/mongodb/LoggingStorage.ts
@@ -85,7 +85,7 @@ export default class LoggingStorage {
}
public static async getLogs(tenantID: string, params: {
- startDateTime?: Date; endDateTime?: Date; levels?: string[]; sources?: string[]; type?: string; actions?: string[];
+ startDateTime?: Date; endDateTime?: Date; levels?: string[]; sources?: string[]; sitesIDs?: string[]; type?: string; actions?: string[];
hosts?: string[]; userIDs?: string[]; search?: string; logIDs?: string[];
} = {}, dbParams: DbParams, projectFields: string[]): Promise<DataResult<Log>> {
// Check Tenant
@@ -118,10 +118,14 @@ export default class LoggingStorage {
if (params.levels && params.levels.length > 0) {
filters.level = { $in: params.levels };
}
- // Filter on charging Stations
- if (params.sources && params.sources.length > 0) {
- filters.source = { $in: params.sources };
+ // Filter on site ID
+ if (params.sitesIDs && params.sitesIDs.length > 0) {
+ filters.siteID = { $in: params.sitesIDs };
}
+ // Filter on charging Stations
+ // if (params.sources && params.sources.length > 0) {
+ // filters.source = { $in: params.sources };
+ // }
// Type
if (params.type) {
filters.type = params.type;

MODIFY
src/types/Log.ts
src/types/Log.ts
@@ -6,7 +6,7 @@ export interface Log {
tenantID: string;
id?: string;
level?: LogLevel;
- siteId?: string;
+ siteID?: string;
source?: string;
host?: string;
process?: string;

Adding changes to add site id logging for site admin