Skip to content

Commit

Permalink
chore: clean up logging
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat committed Nov 26, 2023
1 parent 43e076a commit 28ba68e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/announcement-data/systems/stations/AmeyPhil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4702,6 +4702,7 @@ function LiveTrainAnnouncements({ nextTrainHandler, disruptedTrainHandler, syste
const announceNextTrain = useCallback(
async function announceNextTrain(train: TrainService, abortController: AbortController) {
console.log(train)
addLog(`Announcing next train: ${train.rid} (${train.std} to ${train.destination[0].locationName})`)

markNextTrainAnnounced(train.rid)

Expand All @@ -4710,8 +4711,8 @@ function LiveTrainAnnouncements({ nextTrainHandler, disruptedTrainHandler, syste

const delayMins = calculateDelayMins(new Date(train.std), new Date(train.etd))

addLog(`[Live Trains] Is delayed by ${delayMins} mins`)
console.log(`[Live Trains] Is delayed by ${delayMins} mins`)
addLog(`Train is delayed by ${delayMins} mins`)
console.log(`[Live Trains] Train is delayed by ${delayMins} mins`)

const toc = system.processTocForLiveTrains(train.operator, train.origin[0].crs, train.destination[0].crs)

Expand Down Expand Up @@ -4746,7 +4747,7 @@ function LiveTrainAnnouncements({ nextTrainHandler, disruptedTrainHandler, syste
v.split(/(&|and)/).forEach(via => {
const guessViaCrs = stationNameToCrsMap[via.trim().toLowerCase()]

addLog(`[Live Trains] Guessed via ${guessViaCrs} for ${via}`)
addLog(`Guessed via ${guessViaCrs} for ${via}`)
console.log(`[Live Trains] Guessed via ${guessViaCrs} for ${via}`)

if (guessViaCrs) {
Expand Down Expand Up @@ -4937,15 +4938,19 @@ function LiveTrainAnnouncements({ nextTrainHandler, disruptedTrainHandler, syste
return false
}
if (calculateArrivalInMins(new Date(s.etd)) > MIN_TIME_TO_ANNOUNCE) {
addLog(
`[Live Trains] Skipping ${s.rid} (${std} to ${s.destination[0].locationName}) as it is more than ${MIN_TIME_TO_ANNOUNCE} mins away`,
)
addLog(`Skipping ${s.rid} (${std} to ${s.destination[0].locationName}) as it is more than ${MIN_TIME_TO_ANNOUNCE} mins away`)
console.log(
`[Live Trains] Skipping ${s.rid} (${std} to ${s.destination[0].locationName}) as it is more than ${MIN_TIME_TO_ANNOUNCE} mins away`,
)
return false
}

if (s.atdSpecified) {
addLog(`Skipping ${s.rid} (${std} to ${s.destination[0].locationName}) as it has already departed`)
console.log(`[Live Trains] Skipping ${s.rid} (${std} to ${s.destination[0].locationName}) as it has already departed`)
return false
}

return true
})

Expand Down

0 comments on commit 28ba68e

Please sign in to comment.