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
impl Log
Sourcepub fn new(
level: LogLevel,
tag: &'static str,
message: impl Into<String>,
) -> Self
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);Sourcepub fn trace(tag: &'static str, message: impl Into<String>) -> Self
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");Sourcepub fn debug(tag: &'static str, message: impl Into<String>) -> Self
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");Sourcepub fn info(tag: &'static str, message: impl Into<String>) -> Self
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");Sourcepub fn key(tag: &'static str, message: impl Into<String>) -> Self
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");Sourcepub fn warn(tag: &'static str, message: impl Into<String>) -> Self
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");Sourcepub fn error(tag: &'static str, message: impl Into<String>) -> Self
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));Sourcepub fn with_task_id(self, task_id: impl Into<String>) -> Self
pub fn with_task_id(self, task_id: impl Into<String>) -> Self
Attaches the owning task id.
Sourcepub fn with_key(self, key: impl Into<String>) -> Self
pub fn with_key(self, key: impl Into<String>) -> Self
Attaches the object / blob key being transferred.
Sourcepub fn with_offset(self, offset: u64) -> Self
pub fn with_offset(self, offset: u64) -> Self
Attaches the byte offset within the file.
Sourcepub fn with_byte_len(self, byte_len: u64) -> Self
pub fn with_byte_len(self, byte_len: u64) -> Self
Attaches the byte length of the chunk / range.
Sourcepub fn with_range(self, offset: u64, byte_len: u64) -> Self
pub fn with_range(self, offset: u64, byte_len: u64) -> Self
Attaches both the byte offset and the byte length of a range.
Sourcepub fn with_http_status(self, status: u16) -> Self
pub fn with_http_status(self, status: u16) -> Self
Attaches the HTTP status code associated with a failure.
Sourcepub fn with_attempt(self, attempt: u32) -> Self
pub fn with_attempt(self, attempt: u32) -> Self
Attaches the retry attempt number.
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
Attaches the configured maximum number of retry attempts.
Sourcepub fn with_error_code(self, code: i32) -> Self
pub fn with_error_code(self, code: i32) -> Self
Attaches the SDK error code.
Sourcepub fn with_url(self, url: impl AsRef<str>) -> Self
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.
Sourcepub fn timestamp_ms(&self) -> u64
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();Sourcepub fn level(&self) -> LogLevel
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);Sourcepub fn tag(&self) -> &'static str
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");Sourcepub fn message(&self) -> &str
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");Sourcepub fn object_key(&self) -> Option<&str>
pub fn object_key(&self) -> Option<&str>
Returns the object / blob key, if set.
Sourcepub fn part_index(&self) -> Option<u64>
pub fn part_index(&self) -> Option<u64>
Returns the part / chunk index, if set.
Sourcepub fn http_status(&self) -> Option<u16>
pub fn http_status(&self) -> Option<u16>
Returns the HTTP status code, if set.
Sourcepub fn max_retries(&self) -> Option<u32>
pub fn max_retries(&self) -> Option<u32>
Returns the configured maximum retry attempts, if set.
Sourcepub fn error_code(&self) -> Option<i32>
pub fn error_code(&self) -> Option<i32>
Returns the SDK error code, if set.
Sourcepub fn into_message(self) -> String
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.