Skip to main content

Xlog

Struct Xlog 

Source
pub struct Xlog { /* private fields */ }
Expand description

Handle to a Mars Xlog instance.

Cloning the handle is cheap; the underlying instance is reference-counted and released when the last handle is dropped.

Implementations§

Source§

impl Xlog

Source

pub fn init(config: XlogConfig, level: LogLevel) -> Result<Self, XlogError>

Initialize or reuse a named Xlog instance (recommended entrypoint).

Behavior is idempotent by name_prefix:

  • If no live instance exists for name_prefix, a new instance is created.
  • If a live instance exists with the same config, it is reused.
  • If a live instance exists with a different config, returns XlogError::ConfigConflict.
Source

pub fn get(name_prefix: &str) -> Option<Self>

Look up an existing instance by name prefix.

Source

pub fn instance(&self) -> usize

Returns the raw instance handle used by the underlying C++ library.

Source

pub fn is_enabled(&self, level: LogLevel) -> bool

Returns true if logs at level are enabled for this instance.

Source

pub fn level(&self) -> LogLevel

Get the current log level for this instance.

Source

pub fn set_level(&self, level: LogLevel)

Set the minimum log level for this instance.

Source

pub fn set_appender_mode(&self, mode: AppenderMode)

Switch between async and sync appender modes.

Source

pub fn flush(&self, sync: bool)

Flush buffered logs for this instance.

Source

pub fn set_console_log_open(&self, open: bool)

Enable or disable console logging for this instance (platform dependent).

Source

pub fn set_max_file_size(&self, max_bytes: i64)

Set the max log file size in bytes for this instance (0 disables splitting).

Source

pub fn set_max_alive_time(&self, alive_seconds: i64)

Set the max log file age in seconds for this instance before deletion/rotation.

Source

pub fn log(&self, level: LogLevel, tag: Option<&str>, msg: impl AsRef<str>)

Log a message with caller file/line captured via #[track_caller].

Note: function name is not available here; use xlog! macro or write_with_meta when you need full metadata.

Source

pub fn write(&self, level: LogLevel, tag: Option<&str>, msg: &str)

Compatibility wrapper for older APIs. Prefer log or the macros.

Source

pub fn write_with_meta( &self, level: LogLevel, tag: Option<&str>, file: &str, func: &str, line: u32, msg: &str, )

Log with explicit metadata (file, function, line).

Use this when callers already provide metadata (for example from JNI).

Source

pub fn write_with_meta_raw( &self, level: LogLevel, tag: Option<&str>, file: &str, func: &str, line: u32, msg: &str, raw_meta: RawLogMeta, )

Log with explicit metadata and raw pid/tid/trace flags.

This is mainly for low-level platform wrappers that already own thread metadata (for example JNI side thread ids).

Trait Implementations§

Source§

impl Clone for Xlog

Source§

fn clone(&self) -> Xlog

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Xlog

§

impl !RefUnwindSafe for Xlog

§

impl Send for Xlog

§

impl Sync for Xlog

§

impl Unpin for Xlog

§

impl UnsafeUnpin for Xlog

§

impl !UnwindSafe for Xlog

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more