(dc): change logging to json

This commit is contained in:
Marcel Arndt
2025-04-11 11:58:19 +02:00
parent 46631db5b2
commit dde00abe54
16 changed files with 3674 additions and 3092 deletions
@@ -39,7 +39,7 @@ export class ManagerResolver {
@Subscription(() => TimePerTourUpdateObjectType)
timePerTourUpdated() {
return this.timePerTourKpiService.pubSub.asyncIterator(
return this.timePerTourKpiService.pubSub.asyncIterableIterator(
'timePerTourUpdated',
);
}
@@ -92,7 +92,6 @@ export class TicketLifecycleService {
private async validateCreatedTickets(): Promise<void> {
const tickets = await this.repository.findAllCreated();
this.logger.debug(`Found ${tickets.length} with state CREATED`);
for (const ticket of tickets) {
const {
@@ -362,7 +362,6 @@ export class TicketRepository {
const dwellTimesForTicketState = ticketWithState
.map(({ state }) => {
console.log(state);
const stateToCalculateIdx = state.findIndex(
({ state }) => state === ticketState,
);
@@ -77,6 +77,6 @@ export class TicketsResolver {
@Subscription(() => TicketsUpdatedObjectType)
ticketsUpdated() {
return this.ticketsService.pubSub.asyncIterator('ticketsUpdated');
return this.ticketsService.pubSub.asyncIterableIterator('ticketsUpdated');
}
}
@@ -82,7 +82,7 @@ export class DriverCertificateDetector extends AnomalyDetector {
};
}
} catch (error) {
this.logger.error(error, anomaly.id);
this.logger.error(error, { anomalyId: anomaly.id });
return anomaly;
}
}
@@ -68,7 +68,7 @@ export class EmployeesLoggedInDetector extends AnomalyDetector {
return anomaly;
}
} catch (error) {
this.logger.error(error, anomaly.id);
this.logger.error(error, { anomalyId: anomaly.id });
return anomaly;
}
}
@@ -200,12 +200,11 @@ export class EmployeesLoggedInDetector extends AnomalyDetector {
return false;
}
if (!employee.personnelNumber) {
this.logger.warn(
`Employee has no personnelNumber`,
employee.id,
employee.surname,
employee.name,
);
this.logger.warn(`Employee has no personnelNumber`, {
id: employee.id,
surname: employee.surname,
name: employee.name,
});
return false;
}
return true;
@@ -313,13 +312,12 @@ export class EmployeesLoggedInDetector extends AnomalyDetector {
return [false, undefined];
}
} catch (error) {
this.logger.error(
error,
datetimeToCheck.toISOString(),
this.logger.error(error, {
timeInQuestion: datetimeToCheck.toISOString(),
workTime,
firstClockedIn,
lastClockedOut,
);
});
return [false, undefined];
}
}
@@ -131,12 +131,11 @@ export class OneTourAtATimeDetector extends AnomalyDetector {
tourListInterval,
);
} catch (error) {
this.logger.error(
'tourListInterval',
error,
this.logger.error(error, {
what: 'tourListInterval',
tourListInterval,
tourInterval,
);
});
return false;
}
},
@@ -299,7 +298,7 @@ export class OneTourAtATimeDetector extends AnomalyDetector {
}
return { ...anomaly };
} catch (error) {
this.logger.error(error, anomaly.id);
this.logger.error(error, { anomalyId: anomaly.id });
return anomaly;
}
}
@@ -66,7 +66,7 @@ export class WorkingEmployeeNotInDistributionSystemDetector extends AnomalyDetec
} catch (error) {
this.logger.warn(
`Employee does not exist! PersonnelNumber: ${personnelNumber}`,
error,
{ error },
);
return;
}
@@ -51,7 +51,7 @@ export class CalculationService {
new Date(startDate),
);
if (!tariff) {
this.logger.error(
this.logger.warn(
`No tariff found for tour ${tour.operationId} (${tour.healthInsurance})`,
);
return 0;
@@ -163,11 +163,10 @@ export class CalculationService {
),
);
if (!billingInformation) {
this.logger.error(
"Couldn't find billing information",
this.logger.warn("Couldn't find billing information", {
date: date.toISOString(),
ordinanceType,
date.toISOString(),
);
});
throw new Error("Couldn't find billing information");
}
return billingInformation[1];
@@ -12,7 +12,6 @@ export class PlannedTimeLoader {
const deletedPlannedTimes = stagingPlannedTimes.filter(
({ deleted }) => deleted,
);
console.log(deletedPlannedTimes.length);
const plannedTimesToInsert = stagingPlannedTimes.filter(
({ id }) =>
!!id &&