LogsDebugTab

The Logs tab: the app's own logcat, with a live tail, filters, and a plain-text export, under /api/v1/logs/. The app gives it no data source: the tab runs logcat for its own process.

Register it from debug code, as the Network tab:

Lustro.builder(app).addTab(LogsDebugTab.create()).build().start()

The tab reads logcat from Lustro.start() to Lustro.stop(), also while the app is in the background. It starts with the lines that the process wrote before, from its start. It holds the newest lines in a buffer of bufferBytes on the app's heap, and folds a line that repeats the one before into a count.

In the console, the tab shows a live tail of the log, with filters for the level, the tag, and the message. GET /api/v1/logs/_schema describes its routes.

logcat keeps at most about 4 KB of a message. When the app has a logger of its own, the logger can also give its lines to append, in full, and name their tags with appendedTags of create, so that the tab drops the cut copies that come from logcat, from the first append of each tag on:

val logs = LogsDebugTab.create(appendedTags = { it == "MyApp" })
// In the app's logger, before it writes the line to logcat:
logs.append(Log.DEBUG, "MyApp", message)

Types

Link copied to clipboard
object Companion

Factory for LogsDebugTab.

Properties

Link copied to clipboard
open override val icon: String
Link copied to clipboard
open override val id: String
Link copied to clipboard
open override val order: Int = 20
Link copied to clipboard
Link copied to clipboard
open override val title: String

Functions

Link copied to clipboard
fun append(priority: Int, tag: String, message: String, throwable: Throwable? = null)

Adds a line that the app's own logger writes, with its whole text, to the lines from logcat. The console, GET entries, and GET text show it as one line, with the time, the process, and the thread of this call.

Link copied to clipboard
open fun handle(request: DebugRequest): DebugResponse?
Link copied to clipboard
open override fun onStart()

Starts reading logcat.

Link copied to clipboard
open override fun onStop()

Ends the logcat process. The buffer keeps its lines, and the next start reads on from the newest one.

Link copied to clipboard
open override fun renderContent(): String

The view's static shell; logs.js and logs.css in the assets fill and style it.

Link copied to clipboard
open fun renderScript(): String
Link copied to clipboard
open fun renderStyles(): String
Link copied to clipboard
open fun schema(): String?