Skip to main content

Crate mars_xlog

Crate mars_xlog 

Source
Expand description

Safe Rust wrapper for the Tencent Mars Xlog logging library.

This crate owns the high-level Rust API used by platform bindings and direct Rust integrations. The default release surface is pure Rust and built on top of mars-xlog-core; optional metrics hooks stay feature-gated and out of the default public API.

§Quick start

use mars_xlog::{LogLevel, Xlog, XlogConfig};

let cfg = XlogConfig::new("/tmp/xlog", "demo");
let logger = Xlog::init(cfg, LogLevel::Info).expect("init xlog");
logger.log(LogLevel::Info, None, "hello from rust");
logger.flush(true);

§Feature flags

  • macros: xlog! and level helpers that capture file/module/line.
  • tracing: XlogLayer for tracing-subscriber.
  • metrics: emits structured runtime metrics via the metrics crate.

Macros§

xlog
Log with explicit metadata captured by the macro call site.
xlog_debug
Convenience macro for LogLevel::Debug.
xlog_error
Convenience macro for LogLevel::Error.
xlog_info
Convenience macro for LogLevel::Info.
xlog_warn
Convenience macro for LogLevel::Warn.

Structs§

RawLogMeta
Raw metadata carried by low-level wrappers (JNI/FFI parity path).
Xlog
Handle to a Mars Xlog instance.
XlogConfig
Configuration used to create an Xlog instance or open the global appender.
XlogLayer
tracing-subscriber layer that forwards events to a Xlog instance.
XlogLayerConfig
Configuration for XlogLayer.
XlogLayerHandle
Handle used to toggle a running XlogLayer.

Enums§

AppenderMode
Controls whether logs are appended asynchronously or synchronously.
CompressMode
Compression algorithm used for log buffers/files.
FileIoAction
Result code returned by Xlog::oneshot_flush.
LogLevel
Log severity levels supported by Mars Xlog.
XlogError
Errors returned by Xlog initialization helpers.