Skip to main content

Log

Struct Log 

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

One structured log record that can be printed or persisted externally.

Besides the human-readable Log::message, an entry may carry optional structured context for triage — task id, object key, part index, byte offset/length, HTTP status, retry attempt and a sanitized URL. These are set through the with_* builder methods and are most valuable on LogLevel::Error and LogLevel::Key entries. [Log::Display] appends every present field as key=value, so a persisted log line is self-describing.

Implementations§

Source§

impl Log

Source

pub fn new( level: LogLevel, tag: &'static str, message: impl Into<String>, ) -> Self

Creates a log entry with explicit level and tag (no structured context).

§Examples
use rusty_cat::api::{Log, LogLevel};

let log = Log::new(LogLevel::Info, "demo", "hello");
assert_eq!(log.level(), LogLevel::Info);
Source

pub fn trace(tag: &'static str, message: impl Into<String>) -> Self

Creates a LogLevel::Trace entry (high-frequency; do not persist).

§Examples
use rusty_cat::api::Log;

let log = Log::trace("download_chunk", "wrote chunk");
assert_eq!(log.tag(), "download_chunk");
Source

pub fn debug(tag: &'static str, message: impl Into<String>) -> Self

Creates a LogLevel::Debug entry.

§Examples
use rusty_cat::api::Log;

let log = Log::debug("demo", "debug message");
assert_eq!(log.tag(), "demo");
Source

pub fn info(tag: &'static str, message: impl Into<String>) -> Self

Creates a LogLevel::Info entry.

§Examples
use rusty_cat::api::Log;

let log = Log::info("demo", "info message");
assert_eq!(log.tag(), "demo");
Source

pub fn key(tag: &'static str, message: impl Into<String>) -> Self

Creates a LogLevel::Key entry (key-node checkpoint; persist & forward).

§Examples
use rusty_cat::api::Log;

let log = Log::key("enqueue", "task enqueued");
assert_eq!(log.tag(), "enqueue");
Source

pub fn warn(tag: &'static str, message: impl Into<String>) -> Self

Creates a LogLevel::Warn entry.

§Examples
use rusty_cat::api::Log;

let log = Log::warn("cleanup", "abort failed");
assert_eq!(log.tag(), "cleanup");
Source

pub fn error(tag: &'static str, message: impl Into<String>) -> Self

Creates a LogLevel::Error entry (failure; persist with full context).

§Examples
use rusty_cat::api::Log;

let log = Log::error("upload_part", "part upload failed").with_part(3);
assert_eq!(log.part_index(), Some(3));
Source

pub fn with_task_id(self, task_id: impl Into<String>) -> Self

Attaches the owning task id.

Source

pub fn with_key(self, key: impl Into<String>) -> Self

Attaches the object / blob key being transferred.

Source

pub fn with_part(self, part_index: u64) -> Self

Attaches the zero-based part / chunk index.

Source

pub fn with_offset(self, offset: u64) -> Self

Attaches the byte offset within the file.

Source

pub fn with_byte_len(self, byte_len: u64) -> Self

Attaches the byte length of the chunk / range.

Source

pub fn with_range(self, offset: u64, byte_len: u64) -> Self

Attaches both the byte offset and the byte length of a range.

Source

pub fn with_http_status(self, status: u16) -> Self

Attaches the HTTP status code associated with a failure.

Source

pub fn with_attempt(self, attempt: u32) -> Self

Attaches the retry attempt number.

Source

pub fn with_max_retries(self, max_retries: u32) -> Self

Attaches the configured maximum number of retry attempts.

Source

pub fn with_error_code(self, code: i32) -> Self

Attaches the SDK error code.

Source

pub fn with_url(self, url: impl AsRef<str>) -> Self

Attaches a URL, automatically passing it through sanitize_url so that SAS tokens, signatures and credentials never reach a persisted log.

Source

pub fn timestamp_ms(&self) -> u64

Returns timestamp in milliseconds.

§Examples
use rusty_cat::api::Log;

let log = Log::debug("demo", "message");
let _ts = log.timestamp_ms();
Source

pub fn level(&self) -> LogLevel

Returns log level.

§Examples
use rusty_cat::api::{Log, LogLevel};

let log = Log::new(LogLevel::Warn, "demo", "warn");
assert_eq!(log.level(), LogLevel::Warn);
Source

pub fn tag(&self) -> &'static str

Returns static tag.

§Examples
use rusty_cat::api::Log;

let log = Log::debug("network", "retry");
assert_eq!(log.tag(), "network");
Source

pub fn message(&self) -> &str

Returns message by shared reference.

§Examples
use rusty_cat::api::Log;

let log = Log::debug("demo", "hello");
assert_eq!(log.message(), "hello");
Source

pub fn task_id(&self) -> Option<&str>

Returns the owning task id, if set.

Source

pub fn object_key(&self) -> Option<&str>

Returns the object / blob key, if set.

Source

pub fn part_index(&self) -> Option<u64>

Returns the part / chunk index, if set.

Source

pub fn offset(&self) -> Option<u64>

Returns the byte offset, if set.

Source

pub fn byte_len(&self) -> Option<u64>

Returns the byte length, if set.

Source

pub fn http_status(&self) -> Option<u16>

Returns the HTTP status code, if set.

Source

pub fn attempt(&self) -> Option<u32>

Returns the retry attempt number, if set.

Source

pub fn max_retries(&self) -> Option<u32>

Returns the configured maximum retry attempts, if set.

Source

pub fn error_code(&self) -> Option<i32>

Returns the SDK error code, if set.

Source

pub fn url(&self) -> Option<&str>

Returns the sanitized URL, if set.

Source

pub fn into_message(self) -> String

Consumes the entry and returns owned message.

§Examples
use rusty_cat::api::Log;

let log = Log::debug("demo", "hello");
let msg = log.into_message();
assert_eq!(msg, "hello");

Trait Implementations§

Source§

impl Clone for Log

Source§

fn clone(&self) -> Log

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Log

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Log

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Log

§

impl RefUnwindSafe for Log

§

impl Send for Log

§

impl Sync for Log

§

impl Unpin for Log

§

impl UnsafeUnpin for Log

§

impl UnwindSafe for Log

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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