pub struct LogItem {
pub kind: LogKind,
pub label: Cow<'static, str>,
pub description: Cow<'static, str>,
pub crate_name: Cow<'static, str>,
pub crate_version: Cow<'static, str>,
pub file: Cow<'static, str>,
pub function: Cow<'static, str>,
pub line: u32,
pub err_val: Option<Cow<'static, str>>,
pub validation_status: Option<Cow<'static, str>>,
pub ingredient_uri: Option<Cow<'static, str>>,
}
Expand description
Detailed information about an error or other noteworthy condition.
Use the log_item
macro to create a LogItem
.
Fields§
§kind: LogKind
Kind of log item.
label: Cow<'static, str>
JUBMF label of the item (if available), or other descriptive label
description: Cow<'static, str>
Description of the error
crate_name: Cow<'static, str>
Crate where error was detected
crate_version: Cow<'static, str>
Version of the crate
file: Cow<'static, str>
Source file where error was detected
function: Cow<'static, str>
Function where error was detected
line: u32
Source line number where error was detected
err_val: Option<Cow<'static, str>>
Error code as string
validation_status: Option<Cow<'static, str>>
C2PA validation status code
ingredient_uri: Option<Cow<'static, str>>
Ingredient URI (for ingredient-related logs)
Implementations§
Source§impl LogItem
impl LogItem
Sourcepub fn validation_status(self, status: &'static str) -> Self
pub fn validation_status(self, status: &'static str) -> Self
Add a C2PA validation status code.
§Example
let log = log_item!("test1", "test item 1", "test func").validation_status("claim.missing");
assert_eq!(
log,
LogItem {
kind: LogKind::Informational,
label: Cow::Borrowed("test1"),
description: Cow::Borrowed("test item 1"),
crate_name: Cow::Borrowed(env!("CARGO_PKG_NAME")),
crate_version: Cow::Borrowed(env!("CARGO_PKG_VERSION")),
file: Cow::Borrowed(file!()),
function: Cow::Borrowed("test func"),
line: 7,
validation_status: Some(Cow::Borrowed("claim.missing")),
..Default::default()
}
);
Sourcepub fn set_ingredient_uri<S: Into<String>>(self, uri: S) -> Self
pub fn set_ingredient_uri<S: Into<String>>(self, uri: S) -> Self
Add an ingredient URI.
§Example
let log = log_item!("test1", "test item 1", "test func")
.set_ingredient_uri("self#jumbf=/c2pa/contentauth:urn:uuid:bef41f24-13aa-4040-8efa-08e5e85c4a00/c2pa.assertions/c2pa.ingredient__1");
Sourcepub fn success(self, tracker: &mut impl StatusTracker)
pub fn success(self, tracker: &mut impl StatusTracker)
Set the log item kind to LogKind::Success
and add it to the
StatusTracker
.
Sourcepub fn informational(self, tracker: &mut impl StatusTracker)
pub fn informational(self, tracker: &mut impl StatusTracker)
Set the log item kind to LogKind::Informational
and add it to the
StatusTracker
.
Sourcepub fn failure<E: Debug>(
self,
tracker: &mut impl StatusTracker,
err: E,
) -> Result<(), E>
pub fn failure<E: Debug>( self, tracker: &mut impl StatusTracker, err: E, ) -> Result<(), E>
Set the log item kind to LogKind::Failure
and add it to the
StatusTracker
.
Some implementations are configured to stop immediately on errors. If
so, this function will return Err(err)
.
If the implementation is configured to aggregate all log messages, this
function will return Ok(())
.
Sourcepub fn failure_no_throw<E: Debug>(
self,
tracker: &mut impl StatusTracker,
err: E,
)
pub fn failure_no_throw<E: Debug>( self, tracker: &mut impl StatusTracker, err: E, )
Set the log item kind to LogKind::Failure
and add it to the
StatusTracker
.
Does not return a Result
and thus ignores the StatusTracker
error-handling configuration.