Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add file and line number information to logs
Mikayla Maki624467ebca0b
diff --git a/crates/util/src/util.rs b/crates/util/src/util.rsindex 9d787e1389a..5f738132ae0 100644--- a/crates/util/src/util.rs+++ b/crates/util/src/util.rs@@ -9,6 +9,7 @@ pub mod test;use std::{cmp::{self, Ordering},ops::{AddAssign, Range, RangeInclusive},+ panic::Location,pin::Pin,task::{Context, Poll},};@@ -129,11 +130,13 @@ where{type Ok = T;+ #[track_caller]fn log_err(self) -> Option<T> {match self {Ok(value) => Some(value),Err(error) => {- log::error!("{:?}", error);+ let caller = Location::caller();+ log::error!("{}:{}: {:?}", caller.file(), caller.line(), error);None}}