fix(FileManager,Logging): day-rotated SD logs + boot reset-reason reporting
SD logging was a silent no-op on fresh cards: appendLine() opened /logs/vesper.log in FILE_APPEND without ever creating the /logs directory first. FileManager now exposes appendLogLine(), which creates the directory, rotates to YYYY-MM-DD.log files, and prunes oldest files once a 512KB total budget is exceeded. LoggingHandler gains logs.list / logs.download commands (chunked, paginated) so SD logs can be pulled off a device remotely for offline-device troubleshooting. Telemetry now captures esp_reset_reason() at boot and classifies it as a fault (panic/watchdog/brownout) or an expected reset (power-on/software/deep sleep). CommunicationRouter reports it once MQTT connects: faults go to status/alerts, expected resets go to status/info (type: boot_reason). MQTTDriver gained a setOnConnectCallback hook to support this. F-045, F-046, F-048 in the feature catalog.
This commit is contained in:
+10
-2
@@ -54,6 +54,12 @@ Pass `Logging::NONE` to fully suppress a tag on a channel. The override map is k
|
||||
|
||||
Both channels start disabled (callbacks are `nullptr`). Output on a channel is silenced until the relevant callback is registered.
|
||||
|
||||
### MQTT rate limiting
|
||||
|
||||
Each subsystem tag has its own token bucket on the MQTT channel: a burst of 10 messages, refilling at 1/second. Once a tag's bucket is empty, further messages from that tag are dropped (not queued) until it refills. This protects the broker/airtime from a chatty or misconfigured subsystem — e.g. a per-subsystem override left at `VERBOSE` in the field.
|
||||
|
||||
Drops are not silent: the next time that tag is allowed to publish again, a `WARNING`-level summary line is emitted first (`"suppressed N log message(s) (MQTT rate limit)"`), so a burst is visible even though not every line survived it. Serial and SD channels are unaffected by this limiter — only MQTT.
|
||||
|
||||
### Utilities
|
||||
|
||||
| Method | Description |
|
||||
@@ -86,7 +92,7 @@ Both channels start disabled (callbacks are `nullptr`). Output on a channel is s
|
||||
```
|
||||
`timestamp` is `millis()` (ms since boot), not wall-clock time.
|
||||
|
||||
**SD line (plain text):** `[LEVL][Tag] message (12345ms)`
|
||||
**SD line (plain text):** `[LEVL][Tag] message (12345ms)`, written to a day-rotated file — see [FileManager](../FileManager/README.md#log-file-rotation).
|
||||
|
||||
---
|
||||
|
||||
@@ -112,7 +118,9 @@ This happens immediately after `configManager.begin()`, before any other subsyst
|
||||
|
||||
```cpp
|
||||
Logging::setMqttPublishCallback(..., "vesper/<uid>/logs");
|
||||
Logging::setSdWriteCallback([fm](const String& line) { fm->appendLine("/logs/vesper.log", line); });
|
||||
Logging::setSdWriteCallback([fm](const String& line) {
|
||||
fm->appendLogLine("/logs", line, time(nullptr), SD_LOG_MAX_TOTAL_BYTES);
|
||||
});
|
||||
Logging::setSerialLevel(...);
|
||||
Logging::setMqttLevel(...);
|
||||
Logging::setSdLevel(...);
|
||||
|
||||
Reference in New Issue
Block a user