Expand description
§Bitwarden Logging
Flight Recorder infrastructure for capturing and exporting diagnostic logs.
Internal crate for the bitwarden crate. Do not use.
§Working With FlightRecorder
The Flight Recorder captures tracing events into a global circular buffer so they can be exported for diagnostics without requiring the caller to hold a direct reference to the buffer.
§Initialization
Call init_flight_recorder during SDK startup and add the returned layer to your tracing
subscriber:
use bitwarden_logging::{init_flight_recorder, FlightRecorderConfig};
use tracing_subscriber::{layer::SubscriberExt as _, util::SubscriberInitExt as _};
let flight_recorder_layer = init_flight_recorder(FlightRecorderConfig::default());
tracing_subscriber::registry()
.with(flight_recorder_layer)
.init();The default configuration retains 1 000 events at DEBUG level. Use FlightRecorderConfig::new for
custom settings.
§Reading events
Once initialized, events can be read from anywhere in the process:
use bitwarden_logging::{read_flight_recorder, flight_recorder_count};
let count = flight_recorder_count();
let events = read_flight_recorder();Both functions return safe defaults (0 / empty Vec) if the recorder has not been initialized.
§WASM usage
In bitwarden-wasm-internal, the recorder is automatically initialized by init_sdk(). TypeScript
consumers access it through FlightRecorderClient:
import { FlightRecorderClient } from "@aspect/bitwarden-wasm-internal";
const recorder = new FlightRecorderClient();
const count = recorder.count();
const events = recorder.read();Each FlightRecorderEvent contains timestamp, level, target, message, and fields.
Modules§
- circular_
buffer 🔒 - Thread-safe circular buffer implementation.
- config 🔒
- Configuration for the Flight Recorder.
- event 🔒
- Flight Recorder event definitions.
- global 🔒
- Global Flight Recorder buffer and convenience accessors.
- layer 🔒
- Tracing subscriber layer for Flight Recorder.
- visitor 🔒
- Visitor for extracting fields from tracing events.
Structs§
- Circular
Buffer - A thread-safe circular buffer with FIFO eviction.
- Flight
Recorder Config - Configuration for the Flight Recorder system.
- Flight
Recorder Event - A single log event captured by the Flight Recorder.
- Flight
Recorder Layer - A tracing subscriber layer that captures log events into a circular buffer.
- Message
Visitor - Extracts the message and structured fields from a tracing event.
Functions§
- flight_
recorder_ count - Get the current event count without reading event contents.
- get_
flight_ recorder_ buffer - Get the global Flight Recorder buffer.
- init_
flight_ recorder - Initialize the global Flight Recorder.
- read_
flight_ recorder - Read all events from the global Flight Recorder buffer.