Axonpack

Console

Everything your app logs, on the device, plus a prompt that runs JavaScript and answers.

The Console tab mirrors everything your app logs, on the device. Warnings sit on a yellow row and errors on a red one. The toolbar keeps a running count of warnings, errors and crashes, so you can see at a glance whether anything went wrong while you were not looking.

Console tab listing captured logs

  • Each thing you logged gets its own line, so a message and the object next to it do not run together. Objects and arrays start collapsed. Tap to open them up, level by level.
  • Errors show their message on the row and the full stack when you tap it.
  • Warnings and errors show the file and line that logged them.
  • A crash gets a card of its own in the list. Tap it to open its full report from the Crashes tab.
  • The same message logged over and over becomes one row with a count, so a chatty screen does not bury everything else.
  • Filter by level (each chip carries a live count) or by source, or search the text of every message. Search has match case, whole word and regex, and every match is highlighted where it sits.
  • The newest output stays in view automatically, and stops following if you scroll back to read something, with a button to jump back to the newest.
  • Copy any line with one tap.

Level filter chips showing live counts

Running an expression

An expanded error stack and name suggestions at the prompt

The > prompt at the bottom runs JavaScript on the device and shows you what came back. Your typed command appears with a ›, the answer with a ‹, and objects come back as the same explorable tree. Something that returns a promise shows as pending and fills in when it settles, so fetch(...).then((r) => r.json()) works as you would expect.

  • Names are suggested as you type, including the members of whatever object you are inside.
  • Tap any command you ran earlier to load it straight back into the prompt.
  • Two built-in helpers reach your app's own code in a development build: $modules('auth') lists the files that are loaded, and $m('src/stores/auth') hands you one of them.

The prompt answering an expression

Reaching your own objects

Your app's files are bundled as private closures, so nothing can reach an imported name on its own the way a browser console reaches a page's variables. Anything you want to poke at by name, hand over in context:

<DevtoolsProvider config={{ console: { context: { store, queryClient } } }}>

It is also the only thing that works in a release build, where the module list the two helpers above read is not available.

A support can add names of its own: the preview support adds preview, with what runs now, preview.switch(id) and the other buttons of preview's list. A name in your context wins over a support's.

The devtools command line tool reaches the same names, so an AI agent can use what you hand over here. devtools context lists them, devtools get context store reads one, and devtools context call resetOnboarding --yes calls a function. It can't run anything else: no code is evaluated, and no global is reachable.

npx devtools context
npx devtools context call store.dispatch '{"type":"logout"}' --yes

Redaction

What the CLI reads through context can include a session or a token. console.redactKeys shows a value as [redacted] when its name, a segment of its dot path or a key at any depth inside it matches, and console.redact runs after it for anything else:

<DevtoolsProvider
  config={{
    console: {
      context: { session, store },
      redactKeys: ['token', /secret/i],
      redact: (name, value) =>
        name === 'session.user' ? { ...(value as object), email: '[redacted]' } : value,
    },
  }}
>

It covers the context list, devtools get context and what devtools context call returns, and runs before the CLI prints, cuts or logs a value, so the CLI tab keeps only the redacted reply. When a called function throws, redact also gets its message, as redact(name, message). A function whose name is redacted can still be called; only what it returns is hidden. Both options are empty by default, so nothing is redacted until you list it.

The > prompt itself isn't redacted. It runs any code typed on the device, and code can always reach a value some other way, so redacting its answers would only ever be partial. Its rows show values as they are, in the Console tab and in devtools console.

The prompt is on by default, in every build

console.repl defaults to true, and it is not gated on __DEV__. Wherever the devtools are on, the prompt is there. That includes a release build, where it will run whatever is typed into it. Ship with enabled: false (see Leaving it in production), or turn the prompt off explicitly with console: { repl: false }.

The same list and prompt are on the Console panel of the Axonpack tab in React Native DevTools, with the same levels, filters and search. Filters set on either side show on both.

Limits

  • The list holds the 500 most recent rows.
  • Only console.log, .info, .warn, .error and .debug are mirrored.
  • The prompt cannot reach bundled module names on its own. console.context is the supported route.

Next step

On this page