iOS Live Log Streaming

Stream operational telemetry and live application logs to Didban with a bounded ring buffer, automatic batch uploads, and zero main-thread performance impact.

Log Levels

Didban supports four standard severity levels. The message is always the first argument:

MyViewModel.swiftswift
// Convenience methods — message is the first (unlabeled) argument
Didban.debug("Refreshing user tokens", tag: "auth")
Didban.info("Item added to cart", tag: "cart", attributes: ["sku": "ABC-123", "qty": 2])
Didban.warn("Retrying after timeout", tag: "network", attributes: ["attempt": 2])
Didban.error("Failed to persist cache", tag: "storage", attributes: ["error": "disk_full"])

// Or with explicit LogLevel:
Didban.log("Order submitted", level: .info, tag: "checkout", attributes: ["amount": 49.99])

Manual Flush

Force an immediate upload of pending logs before critical transitions such as ending a VoIP call or signing out:

CheckoutView.swiftswift
Didban.info("Payment confirmed", tag: "checkout", attributes: ["orderId": orderId])
Didban.flush() // ensure the log is uploaded before dismissing the view

How It Works

  • Bounded Ring Buffer: Logs are held in a thread-safe in-memory ring buffer capped at 200 entries. Older entries are automatically evicted.
  • Threshold Batching: Uploads trigger automatically when 20 logs accumulate or every 15 seconds, whichever comes first.
  • Lifecycle Auto-Flush: All pending logs flush automatically on UIApplication.didEnterBackgroundNotification.
  • Non-Blocking: All transmission happens on a background queue — zero main-thread or UI impact.

Structured Attributes

The optional attributes dictionary attaches structured key-value data to the log entry, viewable in the dashboard attributes modal:

NetworkSession.swiftswift
Didban.warn(
    "API request slow",
    tag: "network",
    attributes: [
        "endpoint": "/v1/products",
        "latencyMs": 3200,
        "statusCode": 200,
        "retryCount": 1
    ]
)
Note

Logs are authenticated using the Ingestion Key (didban_ing_...) supplied to Didban.initialize().

Privacy Guidelines

Warning

Never include sensitive data in log messages or attributes. Do not log passwords, authentication tokens, credit card numbers, or personally identifiable information (PII).