Sharpen pilot logging: ISO timestamps, level labels, transport-error classification, per-frame info

- Emit ISO-8601 timestamps and string level labels (info/warn/...) so
  Portainer's log viewer renders seconds and human-readable levels.
- Classify ETIMEDOUT/ECONNRESET/EPIPE/ENOTCONN as info one-liners
  rather than warns with stack traces. These are routine on cellular.
- Add an info "frame ingested" line per accepted AVL frame so device
  activity is visible at info level until task 1.10 wires up prom-client.
This commit is contained in:
2026-04-30 19:30:15 +02:00
parent e2b3bc421c
commit 477fabfef8
2 changed files with 33 additions and 2 deletions
+13 -2
View File
@@ -22,10 +22,19 @@ export function createLogger(options: {
instance_id: instanceId,
};
// Emit `"level":"info"` instead of pino's default `"level":30` so log
// viewers (Portainer, etc.) show a human-readable label rather than the
// numeric level.
const formatters = {
level: (label: string) => ({ level: label }),
};
if (nodeEnv === 'development') {
return pino({
level,
base,
timestamp: pino.stdTimeFunctions.isoTime,
formatters,
transport: {
target: 'pino-pretty',
options: {
@@ -37,6 +46,8 @@ export function createLogger(options: {
});
}
// Production and test: plain JSON — fast, no extra deps
return pino({ level, base });
// Production and test: plain JSON — fast, no extra deps.
// ISO-8601 string timestamps (vs default epoch-ms) survive downstream
// log renderers (Portainer, Docker --timestamps) without losing seconds.
return pino({ level, base, timestamp: pino.stdTimeFunctions.isoTime, formatters });
}