slog2

Crates.ioslog2
lib.rsslog2
version0.1.0
created_at2025-09-13 23:21:49.098929+00
updated_at2025-09-13 23:21:49.098929+00
descriptionA crate that wraps methods defined in `libslog2` in an idomatic rust interface. Also exposes all unsafe c ffi functions via a `ffi` module.
homepage
repositoryhttps://github.com/mounten/slog2
max_upload_size
id1838224
size17,549
Jens Heilmann (mounten)

documentation

README

slog2

License Crates.io Docs.rs

A crate that wraps methods defined in libslog2 in an idomatic rust interface. Also exposes all unsafe c ffi functions via a ffi module.

libslog2 is used to to register and write to logging buffers via the slogger2 system logger daemon.

Usage

Add this to your Cargo.toml:

[dependencies]
slog2 = "0.1"

Example

For more examples examples for how to use this crate.

Register a simple logger buffer:

// Create config
let mut config = slog2::BufferSetConfig::default();
config.buffer_set_name("myprogramm")?;
config.buffer_name("default")?;
config.set_num_pages(7);

// Register and get handle.
let [handle] = config.register(None)?;

// Pass handle as buffer.
slog2::info!(buffer=handle, "Hello World {}", 42);
slog2::info!(buffer=handle, code=1000, "Hello World {}", 42);

Set a default buffer:

// Set a default buffer.
slog2::Buffer::set_default_buffer(Some(buffer_handle));

// Omitting the buffer argument will use the default buffer.
slog2::info!("Hello World {}", 42);
slog2::info!(code=1000, "Hello World {}", 42);

Target Support

This crate was tested for targets aarch64-unknown-nto-qnx800, x86_64-pc-nto-qnx800 with the rustc that is shipped in the qnxsoftwarecenter.

Commit count: 13

cargo fmt