Skip to main content

Crate os_observatory

Crate os_observatory 

Source
Expand description

os_observatory: universal observability primitives for operating systems

This crate provides a zero-dependency, no_std-first toolkit that helps OS authors instrument their kernels with structured logging, low-overhead tracing, and panic reporting. It is designed to compile on bare metal, with optional std support for host-side testing.

Design goals:

  • Independence: no external crate dependencies, only core and optionally alloc/std.
  • Determinism: constant-time operations in interrupt contexts, lock-free paths.
  • Portability: abstract I/O sinks so you can plug in UART, memory, semihosting, etc.
  • Documentation: extensively commented APIs to render well on docs.rs.
  • Testability: host-side tests under std; kernel-side tests via stub sinks.

Modules:

  • sink: trait and implementations for safe output targets
  • logging: macros and logger with compile-time levels
  • tracer: fixed-capacity event tracing buffers with timestamps
  • build: compile-time build information (name, version, etc.)
  • mem: small memory utilities useful in kernels
  • panic: helpers to report panics through your chosen sink

Licensing:

  • MIT License.
  • Authored by an AI Assistant (GPT-5-medium), originating from an idea by alisio85.
  • See LICENSE-MIT for details.

Usage quickstart (no_std):

  • Implement sink::Sink for your hardware writer
  • Initialize a logging::Logger with your sink
  • Use os_log!, os_warn!, os_error!, os_trace! macros
  • Configure tracer::EventTracer for performance-critical instrumentation
  • Wire panic::report_panic inside your panic handler to emit diagnostics

Safety notes:

  • All APIs aim to be no_std and interrupt-safe; avoid heap unless opting into alloc.
  • Logging uses bounded buffers and does not allocate.
  • Tracing uses lock-free atomics and fixed-size records.
  • Panics are reported in a minimalistic, reentrant-aware fashion.

Modules§

build
Build metadata helpers. Compile-time build information.
logging
Structured logging and user-facing macros. Structured logging with compile-time macros.
mem
Memory utilities for OS code. Small memory utilities useful in kernels.
panic
Panic reporting utilities for integration into #[panic_handler]. Panic reporting utilities.
prelude
Re-export commonly used items for convenience. Convenient re-exports for typical usage patterns.
sink
Output abstraction and in-crate sinks. Output sinks for observability.
tracer
Low-overhead event tracing. Event tracing with fixed-capacity buffers.

Macros§

os_error
Logs an error message.
os_log
Logs an informational message.
os_trace
Logs a verbose tracing message.
os_warn
Logs a warning message.