summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-04-14 15:44:43 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-10 19:40:44 +0300
commit04eb8d926f5789812052642d46356a3ad0ade665 (patch)
treefbd27fa8c35f00cda81e94cf01e3c019f6508858
parentea331327b2a468d0cc3a6f6b57b22c3613af3ace (diff)
ui: remove debug_log feature, add log positions
-rw-r--r--Cargo.toml4
-rw-r--r--melib/src/mailbox.rs6
-rw-r--r--melib/src/mailbox/backends/maildir.rs16
-rw-r--r--melib/src/mailbox/backends/maildir/backend.rs72
-rw-r--r--melib/src/mailbox/collection.rs20
-rw-r--r--melib/src/mailbox/email.rs17
-rw-r--r--melib/src/mailbox/email/attachment_types.rs5
-rw-r--r--melib/src/mailbox/email/attachments.rs38
-rw-r--r--melib/src/mailbox/email/parser.rs10
-rw-r--r--melib/src/mailbox/thread.rs58
-rw-r--r--ui/src/components/contacts/contact_list.rs3
-rw-r--r--ui/src/components/mail.rs3
-rw-r--r--ui/src/components/mail/compose.rs10
-rw-r--r--ui/src/components/mail/listing/compact.rs13
-rw-r--r--ui/src/components/mail/listing/mailbox_view.rs23
-rw-r--r--ui/src/components/mail/listing/plain.rs6
-rw-r--r--ui/src/components/mail/listing/thread.rs9
-rw-r--r--ui/src/components/mail/view/thread.rs5
-rw-r--r--ui/src/components/notifications.rs5
-rw-r--r--ui/src/components/utilities.rs3
-rw-r--r--ui/src/conf/accounts.rs20
-rw-r--r--ui/src/state.rs27
-rw-r--r--ui/src/terminal/cells.rs26
-rw-r--r--ui/src/workers.rs5
24 files changed, 241 insertions, 163 deletions
diff --git a/Cargo.toml b/Cargo.toml
index e5431e53..a7f44ac7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,3 @@ lto = true
[workspace]
members = ["melib", "ui"]
-
-[features]
-default = []
-debug_log = []
diff --git a/melib/src/mailbox.rs b/melib/src/mailbox.rs
index 49cc35c6..7a2c65fa 100644
--- a/melib/src/mailbox.rs
+++ b/melib/src/mailbox.rs
@@ -120,7 +120,8 @@ impl Mailbox {
}
pub fn insert_reply(&mut self, envelope: &Envelope) {
- if cfg!(feature = "debug_log") {
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("mailbox insert reply {}", self.name);
}
self.collection.insert_reply(envelope);
@@ -128,6 +129,7 @@ impl Mailbox {
pub fn remove(&mut self, envelope_hash: EnvelopeHash) {
self.collection.remove(envelope_hash);
- // if cfg!(feature = "debug_log") { eprintln!("envelope_hash: {}\ncollection:\n{:?}", envelope_hash, self.collection); }
+ // if cfg!(debug_assertions) { eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ // eprintln!("envelope_hash: {}\ncollection:\n{:?}", envelope_hash, self.collection); }
}
}
diff --git a/melib/src/mailbox/backends/maildir.rs b/melib/src/mailbox/backends/maildir.rs
index 94418f21..30be7d99 100644
--- a/melib/src/mailbox/backends/maildir.rs
+++ b/melib/src/mailbox/backends/maildir.rs
@@ -65,15 +65,18 @@ impl MaildirOp {
fn path(&self) -> PathBuf {
let map = self.hash_index.lock().unwrap();
let map = &map[&self.folder_hash];
- if cfg!(feature = "debug_log") {
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("looking for {} in {} map", self.hash, self.folder_hash);
}
if !map.contains_key(&self.hash) {
- if cfg!(feature = "debug_log") {
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("doesn't contain it though len = {}\n{:#?}", map.len(), map);
}
for e in map.iter() {
- if cfg!(feature = "debug_log") {
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("{:#?}", e);
}
}
@@ -120,7 +123,10 @@ impl<'a> BackendOp for MaildirOp {
'R' => flag |= Flag::REPLIED,
'S' => flag |= Flag::SEEN,
'T' => flag |= Flag::TRASHED,
- _ => eprintln!("DEBUG: in fetch_flags, path is {}", path),
+ _ => {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("DEBUG: in fetch_flags, path is {}", path);
+ }
}
}
@@ -159,6 +165,8 @@ impl<'a> BackendOp for MaildirOp {
new_name.push('T');
}
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("renaming {:?} to {:?}", path, new_name);
fs::rename(&path, &new_name)?;
let hash = envelope.hash();
let hash_index = self.hash_index.clone();
diff --git a/melib/src/mailbox/backends/maildir/backend.rs b/melib/src/mailbox/backends/maildir/backend.rs
index caf9e43f..7f2e3daf 100644
--- a/melib/src/mailbox/backends/maildir/backend.rs
+++ b/melib/src/mailbox/backends/maildir/backend.rs
@@ -135,7 +135,8 @@ fn move_to_cur(p: PathBuf) -> PathBuf {
new.push(file_name);
new.set_extension(":2,");
}
- if cfg!(feature = "debug_log") {
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("moved to cur: {}", new.display());
}
fs::rename(p, &new).unwrap();
@@ -158,14 +159,19 @@ impl MailBackend for MaildirType {
if f.is_valid().is_err() {
continue;
}
- if cfg!(feature = "debug_log") {
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("watching {:?}", f);
}
let mut p = PathBuf::from(&f.path);
p.push("cur");
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("watching {:?}", p);
watcher.watch(&p, RecursiveMode::NonRecursive).unwrap();
p.pop();
p.push("new");
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("watching {:?}", p);
watcher.watch(&p, RecursiveMode::NonRecursive).unwrap();
}
let hash_indexes = self.hash_indexes.clone();
@@ -189,7 +195,12 @@ impl MailBackend for MaildirType {
Ok(event) => match event {
/* Create */
DebouncedEvent::Create(mut pathbuf) => {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("DebouncedEvent::Create(path = {:?}", pathbuf);
if path_is_new!(pathbuf) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("path_is_new");
+ /* This creates a Rename event that we will receive later */
pathbuf = move_to_cur(pathbuf);
}
let folder_hash = get_path_hash!(pathbuf);
@@ -198,6 +209,8 @@ impl MailBackend for MaildirType {
.strip_prefix(&root_path)
.unwrap()
.to_path_buf();
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("cilename is {:?}", file_name);
if let Some(env) = add_path_to_index(
&hash_indexes,
folder_hash,
@@ -205,20 +218,21 @@ impl MailBackend for MaildirType {
&cache_dir,
file_name,
) {
- if cfg!(feature = "debug_log") {
- eprintln!("Create event {} {} {}", env.hash(), env.subject(), pathbuf.display());
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("Create event {} {} {}", env.hash(), env.subject(), pathbuf.display());
}
sender.send(RefreshEvent {
hash: folder_hash,
kind: Create(Box::new(env)),
});
- } else {
- continue;
}
}
/* Update */
DebouncedEvent::NoticeWrite(pathbuf)
| DebouncedEvent::Write(pathbuf) => {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("DebouncedEvent::Write(path = {:?}", pathbuf);
let folder_hash = get_path_hash!(pathbuf);
let mut hash_indexes_lock = hash_indexes.lock().unwrap();
let index_lock = &mut hash_indexes_lock.entry(folder_hash).or_default();
@@ -255,10 +269,13 @@ impl MailBackend for MaildirType {
};
let new_hash: EnvelopeHash = get_file_hash(pathbuf.as_path());
if index_lock.get_mut(&new_hash).is_none() {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("write notice");
let op = Box::new(MaildirOp::new(new_hash, hash_indexes.clone(), folder_hash));
if let Some(env) = Envelope::from_token(op, new_hash) {
- if cfg!(feature = "debug_log") {
- eprintln!("{}\t{}", new_hash, pathbuf.display());
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("{}\t{}", new_hash, pathbuf.display());
}
index_lock.insert(new_hash, pathbuf);
@@ -268,14 +285,17 @@ impl MailBackend for MaildirType {
hash: folder_hash,
kind: Update(old_hash, Box::new(env)),
});
- } else if cfg!(feature = "debug_log") {
- eprintln!("DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`", new_hash, pathbuf.as_path().display());
+ } else if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`", new_hash, pathbuf.as_path().display());
}
}
}
/* Remove */
DebouncedEvent::NoticeRemove(pathbuf)
| DebouncedEvent::Remove(pathbuf) => {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("DebouncedEvent::Remove(path = {:?}", pathbuf);
let folder_hash = get_path_hash!(pathbuf);
let mut hash_indexes_lock = hash_indexes.lock().unwrap();
let index_lock = hash_indexes_lock.entry(folder_hash).or_default();
@@ -284,6 +304,8 @@ impl MailBackend for MaildirType {
{
*k
} else {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("removed but not contained in index");
continue;
};
index_lock.remove(&hash);
@@ -295,6 +317,8 @@ impl MailBackend for MaildirType {
}
/* Envelope hasn't changed, so handle this here */
DebouncedEvent::Rename(src, dest) => {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("DebouncedEvent::Rename(src = {:?}, dest = {:?})", src, dest);
let folder_hash = get_path_hash!(src);
let old_hash: EnvelopeHash = get_file_hash(src.as_path());
let new_hash: EnvelopeHash = get_file_hash(dest.as_path());
@@ -303,6 +327,8 @@ impl MailBackend for MaildirType {
let index_lock = hash_indexes_lock.entry(folder_hash).or_default();
if index_lock.contains_key(&old_hash) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("contains_key");
sender.send(RefreshEvent {
hash: get_path_hash!(dest),
kind: Rename(old_hash, new_hash),
@@ -324,7 +350,9 @@ impl MailBackend for MaildirType {
}
_ => {}
},
- Err(e) => eprintln!("watch error: {:?}", e),
+ Err(e) => {eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("watch error: {:?}", e)
+ }
}
}
})?;
@@ -363,7 +391,8 @@ impl MailBackend for MaildirType {
hostn_buf.trim()
));
}
- if cfg!(feature = "debug_log") {
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("saving at {}", path.display());
}
let file = fs::File::create(path).unwrap();
@@ -579,7 +608,8 @@ impl MaildirType {
}
local_r.push(e);
} else {
- if cfg!(feature = "debug_log") {
+ if cfg!(debug_assertions) {
+eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`", hash, file.as_path().display());
}
continue;
@@ -616,29 +646,28 @@ fn add_path_to_index(
file_name: PathBuf,
) -> Option<Envelope> {
let env: Envelope;
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("add_path_to_index path {:?} filename{:?}", path, file_name);
let hash = get_file_hash(path);
{
let mut map = hash_index.lock().unwrap();
let map = map.entry(folder_hash).or_default();;
map.insert(hash, path.to_path_buf());
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!(
"inserted {} in {} map, len={}",
hash,
folder_hash,
map.len()
);
- for e in map.iter() {
- if cfg!(feature = "debug_log") {
- eprintln!("{:#?}", e);
- }
- }
}
let op = Box::new(MaildirOp::new(hash, hash_index.clone(), folder_hash));
if let Some(e) = Envelope::from_token(op, hash) {
- if cfg!(feature = "debug_log") {
- eprintln!("add_path_to_index gen {}\t{}", hash, file_name.display());
- }
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("add_path_to_index gen {}\t{}", hash, file_name.display());
if let Ok(cached) = cache_dir.place_cache_file(file_name) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ eprintln!("putting in cache");
/* place result in cache directory */
let f = match fs::File::create(cached) {
Ok(f) => f,
@@ -651,6 +680,7 @@ fn add_path_to_index(
}
env = e;
} else {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!(
"DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`",
hash,
diff --git a/melib/src/mailbox/collection.rs b/melib/src/mailbox/collection.rs
index 72bec79a..353de274 100644
--- a/melib/src/mailbox/collection.rs
+++ b/melib/src/mailbox/collection.rs
@@ -59,8 +59,9 @@ impl Collection {
let result: result::Result<Threads, _> = bincode::deserialize_from(reader);
let ret = if let Ok(mut cached_t) = result {
use std::iter::FromIterator;
- if cfg!(feature = "debug_log") {
- eprintln!("loaded cache, our hash set is {:?}\n and the cached one is {:?}", FnvHashSet::from_iter(envelopes.keys().cloned()), cached_t.hash_set);
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("loaded cache, our hash set is {:?}\n and the cached one is {:?}", FnvHashSet::from_iter(envelopes.keys().cloned()), cached_t.hash_set);
}
cached_t.amend(&mut envelopes);
cached_t
@@ -91,8 +92,9 @@ impl Collection {
}
pub fn remove(&mut self, envelope_hash: EnvelopeHash) {
- if cfg!(feature = "debug_log") {
- eprintln!("DEBUG: Removing {}", envelope_hash);
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("DEBUG: Removing {}", envelope_hash);
}
self.envelopes.remove(&envelope_hash);
self.threads.remove(envelope_hash, &mut self.envelopes);
@@ -140,8 +142,9 @@ impl Collection {
pub fn insert(&mut self, envelope: Envelope) {
let hash = envelope.hash();
- if cfg!(feature = "debug_log") {
- eprintln!("DEBUG: Inserting hash {} in {}", hash, self.folder.name());
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("DEBUG: Inserting hash {} in {}", hash, self.folder.name());
}
self.envelopes.insert(hash, envelope);
let env = self.envelopes.entry(hash).or_default() as *mut Envelope;
@@ -153,8 +156,9 @@ impl Collection {
return;
/*
//self.insert(envelope);
- if cfg!(feature = "debug_log") {
- eprintln!("insert_reply in collections");
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("insert_reply in collections");
}
self.threads.insert_reply(envelope, &mut self.envelopes);
*/
diff --git a/melib/src/mailbox/email.rs b/melib/src/mailbox/email.rs
index 82576f78..e73b547f 100644
--- a/melib/src/mailbox/email.rs
+++ b/melib/src/mailbox/email.rs
@@ -385,8 +385,9 @@ impl Envelope {
let (headers, _) = match parser::mail(bytes).to_full_result() {
Ok(v) => v,
Err(e) => {
- if cfg!(feature = "debug_log") {
- eprintln!("error in parsing mail\n{:?}\n", e);
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("error in parsing mail\n{:?}\n", e);
}
let error_msg = String::from("Mail cannot be shown because of errors.");
return Err(MeliError::new(error_msg));
@@ -540,8 +541,9 @@ impl Envelope {
let (headers, body) = match parser::mail(bytes).to_full_result() {
Ok(v) => v,
Err(_) => {
- if cfg!(feature = "debug_log") {
- eprintln!("error in parsing mail\n");
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("error in parsing mail\n");
}
let error_msg = b"Mail cannot be shown because of errors.";
let builder = AttachmentBuilder::new(error_msg);
@@ -573,14 +575,17 @@ impl Envelope {
})
}
pub fn body(&self, mut operation: Box<BackendOp>) -> Attachment {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("searching body for {:?}", self.message_id_display());
let file = operation.as_bytes();
self.body_bytes(file.unwrap())
/*
let (headers, body) = match parser::mail(file.unwrap()).to_full_result() {
Ok(v) => v,
Err(_) => {
- if cfg!(feature = "debug_log") {
- eprintln!("2error in parsing mail\n");
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("2error in parsing mail\n");
}
let error_msg = b"Mail cannot be shown because of errors.";
let mut builder = AttachmentBuilder::new(error_msg);
diff --git a/melib/src/mailbox/email/attachment_types.rs b/melib/src/mailbox/email/attachment_types.rs
index ba9b6102..05b486cd 100644
--- a/melib/src/mailbox/email/attachment_types.rs
+++ b/melib/src/mailbox/email/attachment_types.rs
@@ -68,8 +68,9 @@ impl<'a> From<&'a [u8]> for Charset {
b"BIG5" | b"big5" => Charset::BIG5,
b"ISO-2022-JP" | b"iso-2022-JP" => Charset::ISO2022JP,
_ => {
- if cfg!(feature = "debug_log") {
- eprintln!("unknown tag is {:?}", str::from_utf8(b));
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("unknown tag is {:?}", str::from_utf8(b));
}
Charset::Ascii
}
diff --git a/melib/src/mailbox/email/attachments.rs b/melib/src/mailbox/email/attachments.rs
index ed0a60ab..3f4877d4 100644
--- a/melib/src/mailbox/email/attachments.rs
+++ b/melib/src/mailbox/email/attachments.rs
@@ -143,8 +143,9 @@ impl AttachmentBuilder {
}
}
Err(v) => {
- if cfg!(feature = "debug_log") {
- eprintln!("parsing error in content_type: {:?} {:?}", value, v);
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("parsing error in content_type: {:?} {:?}", value, v);
}
}
}
@@ -211,17 +212,21 @@ impl AttachmentBuilder {
let (headers, body) = match parser::attachment(&a).to_full_result() {
Ok(v) => v,
Err(_) => {
- if cfg!(feature = "debug_log") {
- eprintln!("error in parsing attachment");
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("error in parsing attachment");
}
- if cfg!(feature = "debug_log") {
- eprintln!("\n-------------------------------");
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("\n-------------------------------");
}
- if cfg!(feature = "debug_log") {
- eprintln!("{}\n", ::std::string::String::from_utf8_lossy(a));
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("{}\n", ::std::string::String::from_utf8_lossy(a));
}
- if cfg!(feature = "debug_log") {
- eprintln!("-------------------------------\n");
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("-------------------------------\n");
}
continue;
@@ -245,7 +250,8 @@ impl AttachmentBuilder {
vec
}
a => {
- eprintln!(
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!(
"error {:?}\n\traw: {:?}\n\tboundary: {:?}",
a,
str::from_utf8(raw).unwrap(),
@@ -394,14 +400,16 @@ fn decode_rfc822(_raw: &[u8]) -> Attachment {
builder.build()
/*
- if cfg!(feature = "debug_log") {
- eprintln!("raw is\n{:?}", str::from_utf8(raw).unwrap());
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("raw is\n{:?}", str::from_utf8(raw).unwrap());
}
let e = match Envelope::from_bytes(raw) {
Some(e) => e,
None => {
- if cfg!(feature = "debug_log") {
- eprintln!("error in parsing mail");
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("error in parsing mail");
}
let error_msg = b"Mail cannot be shown because of errors.";
let mut builder = AttachmentBuilder::new(error_msg);
diff --git a/melib/src/mailbox/email/parser.rs b/melib/src/mailbox/email/parser.rs
index 4d84f418..94893f87 100644
--- a/melib/src/mailbox/email/parser.rs
+++ b/melib/src/mailbox/email/parser.rs
@@ -766,11 +766,13 @@ mod tests {
let s = b"Thu, 31 Aug 2017 13:43:37 +0000 (UTC)";
let _s = b"Thu, 31 Aug 2017 13:43:37 +0000";
let __s = b"=?utf-8?q?Thu=2C_31_Aug_2017_13=3A43=3A37_-0000?=";
- if cfg!(feature = "debug_log") {
- eprintln!("{:?}, {:?}", date(s), date(_s));
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("{:?}, {:?}", date(s), date(_s));
}
- if cfg!(feature = "debug_log") {
- eprintln!("{:?}", date(__s));
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("{:?}", date(__s));
}
assert_eq!(date(s).unwrap(), date(_s).unwrap());
assert_eq!(date(_s).unwrap(), date(__s).unwrap());
diff --git a/melib/src/mailbox/thread.rs b/melib/src/mailbox/thread.rs
index c2b8d5fa..6d8ad2d0 100644
--- a/melib/src/mailbox/thread.rs
+++ b/melib/src/mailbox/thread.rs
@@ -574,28 +574,36 @@ impl Threads {
t.create_root_set(collection);
t.build_collection(collection);
- if cfg!(feature = "debug_log") {
- for (i, _t) in t.thread_nodes.iter().enumerate() {
- eprintln!("Thread #{}, children {}", i, _t.children.len());
- if !_t.children.is_empty() {
- eprintln!("{:?}", _t.children);
- }
- if let Some(m) = _t.message {
- eprintln!("\tmessage: {}", collection[&m].subject());
- } else {
- eprintln!("\tNo message");
- }
- }
- eprintln!("\n");
- for (i, _t) in t.tree.borrow().iter().enumerate() {
- eprintln!("Tree #{} id {}, children {}", i, _t.id, _t.children.len());
- if let Some(m) = t.thread_nodes[_t.id].message {
- eprintln!("\tmessage: {}", collection[&m].subject());
- } else {
- eprintln!("\tNo message");
- }
- }
- }
+ //if cfg!(debug_assertions) {
+ // for (i, _t) in t.thread_nodes.iter().enumerate() {
+ // eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ // eprintln!("Thread #{}, children {}", i, _t.children.len());
+ // if !_t.children.is_empty() {
+ // eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ // eprintln!("{:?}", _t.children);
+ // }
+ // if let Some(m) = _t.message {
+ // eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ // eprintln!("\tmessage: {}", collection[&m].subject());
+ // } else {
+ // eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ // eprintln!("\tNo message");
+ // }
+ // }
+ // eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ //eprintln!("\n");
+ // for (i, _t) in t.tree.borrow().iter().enumerate() {
+ // eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ //eprintln!("Tree #{} id {}, children {}", i, _t.id, _t.children.len());
+ // if let Some(m) = t.thread_nodes[_t.id].message {
+ // eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ //eprintln!("\tmessage: {}", collection[&m].subject());
+ // } else {
+ // eprint!("{}:{}_{}: ", file!(), line!(), column!());
+ //eprintln!("\tNo message");
+ // }
+ // }
+ //}
t
}
@@ -839,7 +847,8 @@ impl Threads {
// .iter()
// .position(|n| n.message.map(|n| n == envelope_hash).unwrap_or(false))
// .unwrap();
- // if cfg!(feature = "debug_log") {
+ // if cfg!(debug_assertions) {
+ // eprint!("{}:{}_{}: ", file!(), line!(), column!());
// eprintln!("DEBUG: {} in threads is idx= {}", envelope_hash, pos);
// }
//}
@@ -900,7 +909,8 @@ impl Threads {
let difference: Vec<EnvelopeHash> =
new_hash_set.difference(&self.hash_set).cloned().collect();
for h in difference {
- if cfg!(feature = "debug_log") {
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("inserting {}", collection[&h].subject());
}
let env = collection.entry(h).or_default() as *mut Envelope;
diff --git a/ui/src/components/contacts/contact_list.rs b/ui/src/components/contacts/contact_list.rs
index dd5e7946..3934d50a 100644
--- a/ui/src/components/contacts/contact_list.rs
+++ b/ui/src/components/contacts/contact_list.rs
@@ -89,7 +89,8 @@ impl ContactList {
maxima.1 = std::cmp::max(maxima.1, c.lastname().split_graphemes().len());
maxima.2 = std::cmp::max(maxima.2, c.email().split_graphemes().len());
maxima.3 = std::cmp::max(maxima.3, c.url().split_graphemes().len());
- eprintln!("card = {:?}", c);
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("card = {:?}", c);
}
maxima.0 += 5;
maxima.1 += maxima.0 + 5;
diff --git a/ui/src/components/mail.rs b/ui/src/components/mail.rs
index 61686290..0bfcbb59 100644
--- a/ui/src/components/mail.rs
+++ b/ui/src/components/mail.rs
@@ -86,7 +86,8 @@ impl AccountMenu {
a: &AccountMenuEntry,
context: &mut Context,
) -> usize {
- if cfg!(feature = "debug_log") && !is_valid_area!(area) {
+ if cfg!(debug_assertions) && !is_valid_area!(area) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("BUG: invalid area in print_account");
}
// Each entry and its index in the account
diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs
index c0296844..73c87fe5 100644
--- a/ui/src/components/mail/compose.rs
+++ b/ui/src/components/mail/compose.rs
@@ -501,8 +501,9 @@ impl Component for Composer {
let account = &context.accounts[self.account_cursor];
let draft = std::mem::replace(&mut self.draft, Draft::default());
if let Err(e) = account.save_draft(draft) {
- if cfg!(feature = "debug_log") {
- eprintln!("{:?} could not save draft", e);
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("{:?} could not save draft", e);
}
context.replies.push_back(UIEvent::Notification(
Some("Could not save draft.".into()),
@@ -557,8 +558,9 @@ impl Component for Composer {
.conf()
.sent_folder(),
) {
- if cfg!(feature = "debug_log") {
- eprintln!("{:?} could not save sent msg", e);
+ if cfg!(debug_assertions) {
+ eprint!("{}:{}_{}: ", file!(), line!(), column!());
+eprintln!("{:?} could not save sent msg", e);
}
context.replies.push_back(UIEvent::Notification(
Some("Could not save in 'Sent' folder.".into()),
diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mai