MCPcopy Create free account
hub / github.com/chatmail/core / log_err

Method log_err

src/log.rs:106–128  ·  view source on GitHub ↗
(self, context: &Context)

Source from the content-addressed store, hash-verified

104impl<T, E: std::fmt::Display> LogExt<T, E> for Result<T, E> {
105 #[track_caller]
106 fn log_err(self, context: &Context) -> Result<T, E> {
107 if let Err(e) = &self {
108 let location = std::panic::Location::caller();
109
110 // We are using Anyhow's .context() and to show the inner error, too, we need the {:#}:
111 let full = format!(
112 "{file}:{line}: {e:#}",
113 file = location.file(),
114 line = location.line(),
115 e = e
116 );
117 // We can't use the warn!() macro here as the file!() and line!() macros
118 // don't work with #[track_caller]
119 tracing::event!(
120 ::tracing::Level::WARN,
121 account_id = context.get_id(),
122 "{}",
123 &full
124 );
125 context.emit_event(crate::EventType::Warning(full));
126 };
127 self
128 }
129}
130
131#[cfg(test)]

Callers 15

cmdlineFunction · 0.80
dc_context_openFunction · 0.80
dc_set_configFunction · 0.80
dc_get_configFunction · 0.80
dc_set_stock_translationFunction · 0.80
dc_set_config_from_qrFunction · 0.80
dc_get_infoFunction · 0.80
dc_get_connectivity_htmlFunction · 0.80
dc_get_oauth2_urlFunction · 0.80
spawn_configureFunction · 0.80
dc_is_configuredFunction · 0.80

Calls 1

emit_eventMethod · 0.45

Tested by 1