Skip to content

Commit d786137

Browse files
committed
chore: log task outcomes and boot config for observability
The tasks only logged tick-start/tick-end, so a silent de-dup skip produced no log line at all - making the missing-bulletins issue invisible. - meteo-alerts: log every outcome at info (no-tomorrow-alert / already-handled / recorded-non-critical / sent) and keep the send failure at error. - pretemp, estofex: log when a report is actually sent. - boot: log hasChatId / hasToken / alertZone (no secrets) so a missing channel id or token is visible immediately instead of failing silently. Errors were never hidden by log level (prod resolves to 'info', which emits warn/error/fatal); the gap was the absence of outcome logging.
1 parent 4f4208e commit d786137

4 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ const app = async () => {
4242
database = new PostgreSQL(config.database)
4343
await database.start()
4444
startScheduler()
45+
// Surface the effective notification config at boot (no secrets) so a missing chat id or
46+
// token is obvious in the logs instead of failing silently.
47+
logger.info(
48+
{ hasChatId: !!config.chat_id, hasToken: !!config.telegram_token, alertZone: config.alert_zone },
49+
'Configuration loaded'
50+
)
4551
} catch (error) {
4652
logger.error({ err: error }, 'Application bootstrap failed')
4753
process.exitCode = 1

src/tasks/estofex.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const runEstofexCheck = async (): Promise<'sent' | 'skipped' | 'telegram-
3030
}
3131

3232
await updateLastAlertReport({ estofex_sent: true }, lastAlertReport.id)
33+
log.info({ event: 'sent', reportNumber: lastAlertReport.report_number }, 'Estofex report sent')
3334

3435
return 'sent'
3536
}

src/tasks/meteo-alerts.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const runMeteoAlertCheck = async (): Promise<ParsedMeteoAlert | undefined
1111
const tomorrowAlert = await getTomorrowMeteoAlert()
1212

1313
if (!tomorrowAlert) {
14+
log.info({ event: 'no-tomorrow-alert' }, 'No alert published for tomorrow')
1415
return undefined
1516
}
1617

@@ -21,6 +22,10 @@ export const runMeteoAlertCheck = async (): Promise<ParsedMeteoAlert | undefined
2122
const existing = await getAlertReportByNumber(parsedAlert.id)
2223

2324
if (existing) {
25+
log.info(
26+
{ event: 'already-handled', reportNumber: parsedAlert.id, critic: parsedAlert.isCritic },
27+
'Bulletin already handled'
28+
)
2429
return parsedAlert
2530
}
2631

@@ -38,6 +43,7 @@ export const runMeteoAlertCheck = async (): Promise<ParsedMeteoAlert | undefined
3843
// Non-critical bulletin: just record it (so pretemp/estofex see the latest report); no message.
3944
if (!parsedAlert.isCritic) {
4045
await createAlertReport(report)
46+
log.info({ event: 'recorded-non-critical', reportNumber: parsedAlert.id }, 'Recorded non-critical bulletin')
4147
return parsedAlert
4248
}
4349

@@ -48,6 +54,7 @@ export const runMeteoAlertCheck = async (): Promise<ParsedMeteoAlert | undefined
4854
try {
4955
await sendNewTomorrowAlertMessage(parsedAlert)
5056
await createAlertReport(report)
57+
log.info({ event: 'sent', reportNumber: parsedAlert.id }, 'Meteo alert sent')
5158
} catch (err) {
5259
log.error({ err, alertId: parsedAlert.id }, 'Failed to send meteo alert; will retry next tick')
5360
}

src/tasks/pretemp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const runPretempCheck = async (): Promise<'sent' | 'skipped' | 'telegram-
2727
}
2828

2929
await updateLastAlertReport({ pretemp_sent: true }, lastAlertReport.id)
30+
log.info({ event: 'sent', reportNumber: lastAlertReport.report_number }, 'Pretemp report sent')
3031

3132
return 'sent'
3233
}

0 commit comments

Comments
 (0)