ui: remove debug_log feature, add log positions

embed
Manos Pitsidianakis 2019-04-14 15:44:43 +03:00
parent ea331327b2
commit 04eb8d926f
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
24 changed files with 241 additions and 163 deletions

View File

@ -22,7 +22,3 @@ lto = true
[workspace]
members = ["melib", "ui"]
[features]
default = []
debug_log = []

View File

@ -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); }
}
}

View File

@ -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();

View File

@ -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,

View File

@ -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);
*/

View File

@ -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);

View File

@ -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
}

View File

@ -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);

View File

@ -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());

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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()),

View File

@ -165,15 +165,18 @@ impl MailboxView {
threads.thread_nodes()[iter_ptr].message().unwrap()
};
if !mailbox.collection.contains_key(&i) {
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("key = {}", i);
}
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!(
"name = {} {}",
mailbox.name(),
context.accounts[self.cursor_pos.0].name()
);
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("{:#?}", context.accounts);
}
@ -463,7 +466,8 @@ impl Component for MailboxView {
return true;
}
Action::SubSort(field, order) => {
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("SubSort {:?} , {:?}", field, order);
}
self.subsort = (*field, *order);
@ -471,7 +475,8 @@ impl Component for MailboxView {
return true;
}
Action::Sort(field, order) => {
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("Sort {:?} , {:?}", field, order);
}
self.sort = (*field, *order);

View File

@ -160,16 +160,19 @@ impl MailboxView {
threads.thread_nodes()[iter_ptr].message().unwrap()
};
if !mailbox.collection.contains_key(&i) {
if cfg!(feature = "debug_log") {
eprintln!("key = {}", i);
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("key = {}", i);
}
eprintln!(
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!(
"name = {} {}",
mailbox.name(),
context.accounts[self.cursor_pos.0].name()
);
if cfg!(feature = "debug_log") {
eprintln!("{:#?}", context.accounts);
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("{:#?}", context.accounts);
}
panic!();
@ -459,16 +462,18 @@ impl Component for MailboxView {
return true;
}
Action::SubSort(field, order) => {
if cfg!(feature = "debug_log") {
eprintln!("SubSort {:?} , {:?}", field, order);
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("SubSort {:?} , {:?}", field, order);
}
self.subsort = (*field, *order);
self.refresh_mailbox(context);
return true;
}
Action::Sort(field, order) => {
if cfg!(feature = "debug_log") {
eprintln!("Sort {:?} , {:?}", field, order);
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("Sort {:?} , {:?}", field, order);
}
self.sort = (*field, *order);
self.refresh_mailbox(context);

View File

@ -530,7 +530,8 @@ impl Component for PlainListing {
return true;
}
Action::SubSort(field, order) => {
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("SubSort {:?} , {:?}", field, order);
}
self.subsort = (*field, *order);
@ -539,7 +540,8 @@ impl Component for PlainListing {
return true;
}
Action::Sort(field, order) => {
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("Sort {:?} , {:?}", field, order);
}
self.sort = (*field, *order);

View File

@ -489,7 +489,8 @@ impl Component for ThreadListing {
let account = &mut context.accounts[self.cursor_pos.0];
let (hash, is_seen) = {
let mailbox = &mut account[self.cursor_pos.1].as_mut().unwrap();
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("key is {}", self.locations[dbg!(self.cursor_pos).2]);
}
let envelope: &Envelope =
@ -692,7 +693,8 @@ impl Component for ThreadListing {
return true;
}
Action::SubSort(field, order) => {
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("SubSort {:?} , {:?}", field, order);
}
self.subsort = (*field, *order);
@ -701,7 +703,8 @@ impl Component for ThreadListing {
return true;
}
Action::Sort(field, order) => {
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("Sort {:?} , {:?}", field, order);
}
self.sort = (*field, *order);

View File

@ -873,8 +873,9 @@ impl Component for ThreadView {
let op = context.accounts[self.coordinates.0]
.backend
.operation(envelope.hash(), mailbox.folder.hash());
if cfg!(feature = "debug_log") {
eprintln!(
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!(
"sending action edit for {}, {}",
envelope.message_id(),
op.description()

View File

@ -130,8 +130,9 @@ impl Component for NotificationFilter {
.stdout(Stdio::piped())
.spawn()
{
if cfg!(feature = "debug_log") {
eprintln!("{:?}", v);
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("{:?}", v);
}
}
}

View File

@ -1072,7 +1072,8 @@ impl Component for Tabbed {
self.set_dirty();
return true;
} else {
eprintln!(
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!(
"DEBUG: Child component with id {:?} not found.\nList: {:?}",
id, self.children
);

View File

@ -91,14 +91,6 @@ impl<'a> Iterator for MailboxIterator<'a> {
type Item = Option<&'a Mailbox>;
fn next(&mut self) -> Option<Option<&'a Mailbox>> {
eprintln!(
"self.pos = {}, iter.len {}",
self.pos,
self.folders[self.pos..]
.iter()
.collect::<Vec<&Option<Result<Mailbox>>>>()
.len()
);
if self.pos == self.folders.len() {
return None;
}
@ -138,7 +130,8 @@ impl Account {
.iter()
.position(|x: &Folder| x.name() == settings.account().sent_folder);
if let Some(folder_confs) = settings.conf().folders() {
//if cfg!(feature = "debug_log") {
//if cfg!(debug_assertions) {
//eprint!("{}:{}_{}: ", file!(), line!(), column!());
//eprintln!("folder renames: {:?}", folder_renames);
//}
for f in &mut ref_folders {
@ -213,14 +206,16 @@ impl Account {
return Some(EnvelopeUpdate(old_hash));
}
RefreshEventKind::Rename(old_hash, new_hash) => {
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("rename {} to {}", old_hash, new_hash);
}
mailbox!(idx, self.folders).rename(old_hash, new_hash);
return Some(EnvelopeRename(idx, old_hash, new_hash));
}
RefreshEventKind::Create(envelope) => {
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("create {}", envelope.hash());
}
let env: &Envelope = mailbox!(idx, self.folders).insert(*envelope);
@ -266,7 +261,8 @@ impl Account {
pub fn list_folders(&self) -> Vec<Folder> {
let mut folders = self.backend.folders();
if let Some(folder_confs) = self.settings.conf().folders() {
//if cfg!(feature = "debug_log") {
//if cfg!(debug_assertions) {
//eprint!("{}:{}_{}: ", file!(), line!(), column!());
//eprintln!("folder renames: {:?}", folder_renames);
//}
for f in &mut folders {

View File

@ -239,13 +239,15 @@ impl State {
)
.unwrap();
s.flush();
if cfg!(feature = "debug_log") {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("DEBUG: inserting mailbox hashes:");
}
for (x, account) in s.context.accounts.iter_mut().enumerate() {
for (y, folder) in account.backend.folders().iter().enumerate() {
if cfg!(feature = "debug_log") {
eprintln!("{:?}", folder);
for folder in account.backend.folders().values() {
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("hash & folder: {:?} {}", folder.hash(), folder.name());
}
s.context.mailbox_hashes.insert(folder.hash(), (x, y));
}
@ -348,6 +350,7 @@ impl State {
if termcols.unwrap_or(72) as usize != self.cols
|| termrows.unwrap_or(120) as usize != self.rows
{
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!(
"Size updated, from ({}, {}) -> ({:?}, {:?})",
self.cols, self.rows, termcols, termrows
@ -497,22 +500,6 @@ impl State {
}
}
/// Tries to load a mailbox's content
pub fn refresh_mailbox(&mut self, account_idx: usize, folder_idx: usize) {
let flag = match &mut self.context.accounts[account_idx][folder_idx] {
Ok(_) => true,
Err(e) => {
if cfg!(feature = "debug_log") {
eprintln!("error {:?}", e);
}
false
}
};
if flag {
self.rcv_event(UIEvent::RefreshMailbox((account_idx, folder_idx)));
}
}
pub fn try_wait_on_child(&mut self) -> Option<bool> {
let should_return_flag = match self.child {
Some(ForkType::NewDraft(_, ref mut c)) => {

View File

@ -574,7 +574,8 @@ pub fn copy_area_with_break(
src: Area,
) -> Pos {
if !is_valid_area!(dest) || !is_valid_area!(src) {
eprintln!(
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!(
"BUG: Invalid areas in copy_area:\n src: {:?}\n dest: {:?}",
src, dest
);
@ -621,7 +622,8 @@ pub fn copy_area_with_break(
/// Copy a source `Area` to a destination.
pub fn copy_area(grid_dest: &mut CellBuffer, grid_src: &CellBuffer, dest: Area, src: Area) -> Pos {
if !is_valid_area!(dest) || !is_valid_area!(src) {
eprintln!(
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!(
"BUG: Invalid areas in copy_area:\n src: {:?}\n dest: {:?}",
src, dest
);
@ -637,8 +639,9 @@ pub fn copy_area(grid_dest: &mut CellBuffer, grid_src: &CellBuffer, dest: Area,
let mut src_y = get_y(upper_left!(src));
let (cols, rows) = grid_src.size();
if src_x >= cols || src_y >= rows {
if cfg!(feature = "debug_log") {
eprintln!("DEBUG: src area outside of grid_src in copy_area",);
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("DEBUG: src area outside of grid_src in copy_area",);
}
return upper_left!(dest);
}
@ -676,14 +679,16 @@ pub fn change_colors(grid: &mut CellBuffer, area: Area, fg_color: Color, bg_colo
|| y >= get_y(bounds)
|| x >= get_x(bounds)
{
if cfg!(feature = "debug_log") {
eprintln!("BUG: Invalid area in change_colors:\n area: {:?}", area);
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("BUG: Invalid area in change_colors:\n area: {:?}", area);
}
return;
}
if !is_valid_area!(area) {
if cfg!(feature = "debug_log") {
eprintln!("BUG: Invalid area in change_colors:\n area: {:?}", area);
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("BUG: Invalid area in change_colors:\n area: {:?}", area);
}
return;
}
@ -734,8 +739,9 @@ pub fn write_string_to_grid(
|| y > get_y(bounds)
|| x > get_x(bounds)
{
if cfg!(feature = "debug_log") {
eprintln!(" Invalid area with string {} and area {:?}", s, area);
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!(" Invalid area with string {} and area {:?}", s, area);
}
return (x, y);
}

View File

@ -226,8 +226,9 @@ impl WorkController {
}
// Report the amount of work done.
if cfg!(feature = "debug_log") {
eprintln!("Thread {} did {} jobs.", thread_num, work_done);
if cfg!(debug_assertions) {
eprint!("{}:{}_{}: ", file!(), line!(), column!());
eprintln!("Thread {} did {} jobs.", thread_num, work_done);
}
});