Android Live Log Streaming

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

Log Levels

Didban supports four standard severity levels. Use the convenience methods or the general-purpose log with an explicit LogLevel:

MyViewModel.ktkotlin
// Convenience methods — message is the first argument
Didban.debug("Refreshing access token", tag = "auth")
Didban.info("Item added to cart", tag = "cart", attributes = mapOf("sku" to "ABC-123", "qty" to 2))
Didban.warn("Retrying request after timeout", tag = "network", attributes = mapOf("attempt" to 2))
Didban.error("Failed to write user cache", tag = "database", attributes = mapOf("error" to "disk_full"))

// Or with explicit LogLevel:
Didban.log("Order submitted", level = LogLevel.INFO, tag = "checkout", attributes = mapOf("amount" to 49.99))

Manual Flush

Force an immediate upload of any queued logs before critical transitions such as signing out or completing a purchase:

CheckoutActivity.ktkotlin
Didban.info("Payment confirmed", tag = "checkout", attributes = mapOf("orderId" to orderId))
Didban.flush() // ensure the log is uploaded before finishing the activity

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 when the app enters the background.
  • Non-Blocking: All transmission happens on a background coroutine — zero main-thread impact.

Structured Attributes

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

NetworkClient.ktkotlin
Didban.warn(
    "API request slow",
    tag = "network",
    attributes = mapOf(
        "endpoint" to "/v1/products",
        "latencyMs" to 3200,
        "statusCode" to 200,
        "retryCount" to 1
    )
)
Note

Logs are authenticated using the Ingestion Key (didban_ing_...) supplied to Didban.init(). The Build / CI key is never used for log transmission.

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).