pub struct Log { /* private fields */ }Expand description
One structured log record that can be printed or persisted externally.
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.
§Examples
use rusty_cat::api::{Log, LogLevel};
let log = Log::new(LogLevel::Info, "demo", "hello");
assert_eq!(log.level(), LogLevel::Info);Sourcepub fn debug(tag: &'static str, message: impl Into<String>) -> Self
pub fn debug(tag: &'static str, message: impl Into<String>) -> Self
Creates a debug-level log entry.
§Examples
use rusty_cat::api::Log;
let log = Log::debug("demo", "debug message");
assert_eq!(log.tag(), "demo");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 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
Mutably borrows from an owned value. Read more
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.