Mob.NativeLogger (mob v0.6.7)

Copy Markdown View Source

OTP logger handler that routes Elixir Logger output to the platform's native system log.

  • Androidmob_nif:log/2android.util.Logadb logcat
  • iOSmob_nif:log/2NSLog → unified system log (Xcode console, xcrun simctl spawn booted log stream)

Each message appears with the correct priority level (D/I/W/E) under the tag Elixir. OTP supervision reports, GenServer crashes, and all Logger.info/warn/error calls are captured from the first BEAM instruction, including boot-time failures that happen before Erlang distribution comes up.

Usage

Call install/0 once after application:start(logger) in your BEAM entry point (e.g. mob_demo.erl):

'Elixir.Mob.NativeLogger':install()

On the host Mix environment (:host platform) the call is a no-op, so the same boot file works unchanged during mix test and local development.

Relationship to Erlang distribution

This handler and dist-based log forwarding are complementary. Native logging is always-on and survives connection drops; dist forwarding surfaces logs in the mob_dev dashboard. Both can be active simultaneously — OTP supports multiple logger handlers.

Summary

Functions

Installs the native system log handler.

Functions

install(opts \\ [])

@spec install(keyword()) :: :ok

Installs the native system log handler.

Checks the platform via the NIF; if :host, returns :ok without adding any handler. Safe to call multiple times.

Options:

  • :nif — NIF module to use (default :mob_nif; override in tests)