Configuration¶
DebugConfig holds the options of the server and of the Network tab's capture. Build one with
DebugConfig.builder() and give it to the Lustro builder. An option that you do not set keeps its
default:
val lustro = Lustro.builder(application)
.config(
DebugConfig.builder()
.serverPort(8081)
.captureBudgetBytes(100L * 1024 * 1024)
.build(),
)
.addTab(NetworkDebugTab.create())
.build()
Without config(...), Lustro uses DebugConfig.DEFAULT. lustro-noop has the same
DebugConfig, so this code compiles in a release build too.
Server¶
| Option | Type | Default | Effect |
|---|---|---|---|
allowNonDebuggableBuilds |
Boolean |
false |
When true, start() opens the server in a build without android:debuggable. Only for internal builds: see Release safety. |
serverPort |
Int |
8080 |
The port that the server binds on the device. Forward the same port: adb forward tcp:8081 tcp:8081. The CLI reads the port from the LustroToken line. UI tests that start WireMock in the app's process use 8080 too: see Instrumentation tests. Give each app with Lustro on one device its own port, such as 8080 for the debug build and 8081 for a staging build: two apps on the same port take turns, and right after one starts, the server of the other answers its requests with 401 until that app goes to the background. See Troubleshooting. |
bindAddress |
String |
"127.0.0.1" |
The address that the server binds. "0.0.0.0" makes it reachable from the network, and the server then makes a new token with each process of the app: see LAN exposure. |
bindFallback |
Boolean |
false |
When serverPort is taken: with true, the server binds a port that the system picks, and the LustroToken line gives it. With false, it tries serverPort again for 10 s, then waits for the next foreground. |
allowedOrigins |
List<String> |
empty | More origins that a browser can call the API from, on every method, such as "http://192.168.1.42:8080". The server's own origin is always allowed. Other ports of localhost are not. See Security model. |
Requests to the server¶
These options limit the requests to /api/v1/, the routes of every tab. The page and its
assets, such as /tab/<id> and /shared.js, are outside the limits. The options are global: a
tab cannot set its own. A tab that needs a larger body or a longer timeout raises the value here,
for every tab, and work that takes longer than the timeout goes in the background (see
Long work).
| Option | Type | Default | Effect |
|---|---|---|---|
maxRequestBodyBytes |
Long |
1 MiB (1L * 1024 * 1024) |
The largest request body. A larger one gets a 413, and the server does not read it. The server holds at most maxConcurrentRequests x maxRequestBodyBytes of bodies in memory at a time: a body that does not fit waits for room. |
maxConcurrentRequests |
Int |
16 |
How many requests the tabs handle at the same time. A request that timed out keeps its slot until its handler returns. |
requestQueueCapacity |
Int |
64 |
How many requests wait for a slot. A request that waits longer than requestTimeoutMs, or that finds the queue full, gets a 503. The server keeps at most maxConcurrentRequests + requestQueueCapacity + 16 connections open. |
requestTimeoutMs |
Long |
30000 |
How long a tab can take for one request. A request that runs longer gets a 504, and the server cancels it: see Custom tabs. The Network tab's Send form also stops a request that it sends after this time. |
Network tab capture¶
build() gives these options to the Network tab. They have no effect on
the other tabs.
| Option | Type | Default | Effect |
|---|---|---|---|
maxCaptureTransactions |
Int |
1000 |
How many HTTP transactions the tab keeps. Past it, the oldest go first. |
captureBudgetBytes |
Long |
50 MiB (50L * 1024 * 1024) |
The memory for the bodies that the tab keeps. A body that the tab does not keep, such as a media download, costs nothing. Past the budget, the oldest finished transactions go first. |
maxBodyCaptureBytes |
Long |
256 KiB (256L * 1024) |
The bytes kept of each request body, each response body, and each WebSocket message. The Send form also reads at most this much of a response: see Send Request. |
maxCaptureWebSockets |
Int |
100 |
How many WebSocket connections the tab keeps. See WebSocket messages. |
maxWebSocketEvents |
Int |
1000 |
How many messages and lifecycle events the tab keeps for each WebSocket connection. |
webSocketCaptureBudgetBytes |
Long |
16 MiB (16L * 1024 * 1024) |
The memory for all the WebSocket message payloads that the tab keeps. |
appServerBaseUrl |
String? |
null |
The base URL for a relative URL in the Send form, when the tab sends through NetworkDebugTab.create(senderClient = ...). A sender from OkHttpSender.create has its own base URL, which can be a function for a server that changes at runtime. See Send Request. |
The options of each tab¶
The other options belong to a tab, and its factory takes them, such as the redactor and the mock rule storage of the Network tab, or the value policy of a Preferences file. Each tab's page lists them:
| Tab | Factory | Options |
|---|---|---|
| Network | NetworkDebugTab.create(...) |
OkHttp capture setup, Send Request, Mock rules, Platform HttpURLConnection capture |
| Logs | LogsDebugTab.create(...) |
Register the tab, Safety options |
| Preferences | PrefsDebugTab.create(...) |
Register the tab, Safety options |
| SQLite | SqliteDebugTab.create(...) |
Register the tab, Safety options |
| WorkManager | WorkDebugTab.create(...) |
Register the tab, Safety options |
| Screen | ScreenDebugTab.create(...) |
Register the tab, Safety options |
The Kotlin API reference has the KDoc of DebugConfig
and of each factory.