Observability: DEBUG debug-level default, greppable decision tags, log export + UDP LAN sink

Debugging the integration build on real iOS 26.5 devices over the air.

- BitLogger DEBUG default minimumLevel now .debug (was .info) so a
  tap-launched sideload surfaces .debug decision logs without the
  BITCHAT_LOG_LEVEL env var; env still wins; release unchanged (.info,
  emits nothing). Extracted defaultMinimumLevel + a test asserting it.
- Greppable bracket decision tags at .info (visible even at .info) via
  SecureLogger, ID-prefixes only, sanitized:
  [ROUTE] source-route vs flood origination (+reason) + fragment
  targeted-resync; [GW] uplink accept/reject, downlink rebroadcast/drop,
  loop skips, drain-timer; [WIFI] offer/accept/decline, AWDL connect,
  transfer start/complete+bytes, fallback+reason; [PREKEY] seal choice,
  consume, unknown-prekey open fail, bundle ingest, re-gossip;
  [SYNC] one concise summary per cycle + per-request served counts (no
  per-packet spam); [PING]/[TRACE] RTT + computed path.
- New OSLog categories: mesh, gateway, transport.
- Refactored BLESourceRouteOriginationPolicy.route -> decide returning a
  Decision enum (flood(reason)/route(hops)) so the flood reason is
  greppable and unit-tested.
- DEBUG-only in-memory ring buffer (LogExportBuffer, ~2000 lines/512KB,
  thread-safe, off main thread) + App Info "Export Logs" share sheet
  (iOS UIActivityViewController / macOS NSSavePanel), VoiceOver labels.
- DEBUG-only UDP LAN log sink (LogNetworkSink): opt-in, off by default,
  fire-and-forget, never blocks/throws; each line prefixed with the
  device nickname for demux; configured via App Info host:port fields.
  Same sanitized formatted line feeds buffer, sink, and export.

All new code is #if DEBUG; release emits nothing and ships no export/sink UI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jack
2026-07-06 23:04:33 +02:00
co-authored by Claude Fable 5
parent e0e90af9fd
commit 02aa1d67db
16 changed files with 530 additions and 63 deletions
@@ -51,4 +51,25 @@ final class LogLevelFilteringTests: XCTestCase {
XCTAssertEqual(counter.count, 1, "Enabled levels must still log")
}
/// A sideloaded, tap-launched build can't receive BITCHAT_LOG_LEVEL, so the
/// DEBUG default must be `.debug` (not `.info`) or the `.debug` decision
/// logs stay invisible on device. Release still defaults to `.info` and
/// emits nothing regardless (all log paths are `#if DEBUG`).
func testDebugBuildDefaultsToDebugLevelUnlessOverridden() throws {
// Only meaningful when the env override isn't set (CI sometimes sets it).
try XCTSkipUnless(
ProcessInfo.processInfo.environment["BITCHAT_LOG_LEVEL"] == nil,
"BITCHAT_LOG_LEVEL is set; default-level assertion doesn't apply"
)
#if DEBUG
XCTAssertEqual(
SecureLogger.defaultMinimumLevel,
.debug,
"DEBUG builds must default to .debug so tap-launched sideloads surface decision logs"
)
#else
XCTAssertEqual(SecureLogger.defaultMinimumLevel, .info)
#endif
}
}