Available on Apple only.
Expand description
A [tracing_subscriber] layer for Apple unified logging.
OsLogLayer writes tracing events to an Apple os_log_t. By default,
spans are represented as signpost intervals for inspection in Instruments.
Each interval measures the span’s lifetime from creation until final close,
rather than only the time during which the span is entered. Span context in
event messages remains optional and is disabled by default.
The layer checks whether Apple logging is enabled for an event’s mapped
level before it visits or formats that event. This check is deliberately
performed inside [Layer::on_event]: returning false from
[Layer::enabled] would disable the event for every other layer in the
subscriber stack as well.
§Example
use rama::telemetry::tracing::{
self,
apple::oslog::{OsLogLayer, Privacy},
subscriber::{layer::SubscriberExt as _, util::SubscriberInitExt as _},
};
let oslog = OsLogLayer::new("com.example.proxy", "network")?
.with_privacy(Privacy::Public)
.with_span_context(true);
tracing::subscriber::registry().with(oslog).try_init()?;Structs§
- Level
Map - Maps tracing levels to Apple unified-log types.
- OsLog
Layer - A composable [
tracing_subscriber::Layer] that writes to Apple unified logging.
Enums§
- OsLog
Error - Failure to create an Apple unified-log layer.
- OsLog
Type - Native Apple unified-log types.
- Privacy
- Privacy applied to the event or signpost’s dynamic text.
- Span
Mode - Controls whether tracing spans are exported as Apple signposts.