Logging
This platform uses the tracing ecosystem to record application state and performance information. Structured logging allows you to attach context to messages, facilitating diagnostics in concurrent 3D environments.
Log Levels
Choosing the appropriate level ensures that logs remain useful:
- Error: Critical issues requiring immediate attention (e.g., failed network connections).
- Warning: Potential problems that do not halt the application but should be reviewed.
- Information: High-level events tracking progress (e.g., “Starting project synchronization”).
- Debugging: Detailed internal information for development, typically filtered in production.
Log Destinations
By default, the client directs log events to two destinations:
- Live Console: Printed directly to the terminal for immediate feedback.
- Rotating Log Files: Maintained on the local disk to diagnose issues in the field.
Spans and Context
The tracing crate uses Spans to represent periods of time with associated data. When you log inside a span, that context is automatically attached to the message.
This is useful for concurrent operations. For example, if processing data for multiple projects, you can wrap each process in a span that includes a project ID. Every log message generated by that process will be tagged with that ID.
use tracing::{info, info_span};
// Create a context for the current operation
let span = info_span!("sync_operation", project_id = %id);
let _enter = span.enter();
info!("Starting data synchronization");
// This log message automatically knows it belongs to 'project_id'
Telemetry
Because spans track duration, the logging infrastructure can also serve as a performance profiler. By wrapping key systems in spans, you can view execution times in the Built-in Profiler.
The SDK can be extended with additional Subscribers. SpatialDrive includes optional support for Sentry. Critical errors can be automatically reported to a central monitoring system. Custom subscribers can also be added to direct telemetry to internal analysis tools.