drop tracing for fern

This commit is contained in:
Michael Zhang 2021-02-22 01:37:19 -06:00
parent 797ce61ef4
commit 68b0b70ffd
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
11 changed files with 70 additions and 222 deletions

198
Cargo.lock generated
View file

@ -9,15 +9,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.38" version = "1.0.38"
@ -152,7 +143,7 @@ version = "2.33.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
dependencies = [ dependencies = [
"ansi_term 0.11.0", "ansi_term",
"atty", "atty",
"bitflags", "bitflags",
"strsim 0.8.0", "strsim 0.8.0",
@ -161,6 +152,17 @@ dependencies = [
"vec_map", "vec_map",
] ]
[[package]]
name = "colored"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59"
dependencies = [
"atty",
"lazy_static",
"winapi",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.1" version = "0.9.1"
@ -177,27 +179,6 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"
[[package]]
name = "crossbeam-channel"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
dependencies = [
"cfg-if",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d"
dependencies = [
"autocfg",
"cfg-if",
"lazy_static",
]
[[package]] [[package]]
name = "crossterm" name = "crossterm"
version = "0.19.0" version = "0.19.0"
@ -292,6 +273,16 @@ dependencies = [
"ascii_utils", "ascii_utils",
] ]
[[package]]
name = "fern"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9a4820f0ccc8a7afd67c39a0f1a0f4b07ca1725164271a64939d7aeb9af065"
dependencies = [
"colored",
"log",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
@ -575,15 +566,6 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "matchers"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
dependencies = [
"regex-automata",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.3.4" version = "2.3.4"
@ -748,10 +730,12 @@ dependencies = [
"cfg-if", "cfg-if",
"chrono", "chrono",
"crossterm", "crossterm",
"fern",
"format-bytes", "format-bytes",
"futures", "futures",
"inotify", "inotify",
"lettre", "lettre",
"log",
"panorama-imap", "panorama-imap",
"parking_lot", "parking_lot",
"pin-project", "pin-project",
@ -763,9 +747,6 @@ dependencies = [
"tokio-stream", "tokio-stream",
"tokio-util", "tokio-util",
"toml", "toml",
"tracing",
"tracing-appender",
"tracing-subscriber",
"webpki-roots", "webpki-roots",
"xdg", "xdg",
] ]
@ -778,12 +759,12 @@ dependencies = [
"assert_matches", "assert_matches",
"derive_builder", "derive_builder",
"futures", "futures",
"log",
"nom 6.1.2", "nom 6.1.2",
"owning_ref", "owning_ref",
"parking_lot", "parking_lot",
"tokio", "tokio",
"tokio-rustls", "tokio-rustls",
"tracing",
"webpki-roots", "webpki-roots",
] ]
@ -965,31 +946,6 @@ dependencies = [
"bitflags", "bitflags",
] ]
[[package]]
name = "regex"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4"
dependencies = [
"byteorder",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
[[package]] [[package]]
name = "remove_dir_all" name = "remove_dir_all"
version = "0.5.3" version = "0.5.3"
@ -1137,15 +1093,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "sharded-slab"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3"
dependencies = [
"lazy_static",
]
[[package]] [[package]]
name = "signal-hook" name = "signal-hook"
version = "0.1.17" version = "0.1.17"
@ -1277,15 +1224,6 @@ dependencies = [
"unicode-width", "unicode-width",
] ]
[[package]]
name = "thread_local"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd"
dependencies = [
"once_cell",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.44" version = "0.1.44"
@ -1376,92 +1314,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "tracing"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f77d3842f76ca899ff2dbcf231c5c65813dea431301d6eb686279c15c4464f12"
dependencies = [
"cfg-if",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-appender"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9965507e507f12c8901432a33e31131222abac31edd90cabbcf85cf544b7127a"
dependencies = [
"chrono",
"crossbeam-channel",
"tracing-subscriber",
]
[[package]]
name = "tracing-attributes"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f"
dependencies = [
"lazy_static",
]
[[package]]
name = "tracing-log"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-serde"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b"
dependencies = [
"serde",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ab8966ac3ca27126141f7999361cc97dd6fb4b71da04c02044fa9045d98bb96"
dependencies = [
"ansi_term 0.12.1",
"chrono",
"lazy_static",
"matchers",
"regex",
"serde",
"serde_json",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
"tracing-serde",
]
[[package]] [[package]]
name = "unicode-segmentation" name = "unicode-segmentation"
version = "1.7.1" version = "1.7.1"

View file

@ -17,10 +17,12 @@ async-trait = "0.1.42"
cfg-if = "1.0.0" cfg-if = "1.0.0"
chrono = "0.4.19" chrono = "0.4.19"
crossterm = "0.19.0" crossterm = "0.19.0"
fern = { version = "0.6.0", features = ["colored"] }
format-bytes = "0.2.0" format-bytes = "0.2.0"
futures = "0.3.12" futures = "0.3.12"
inotify = { version = "0.9.2", features = ["stream"] } inotify = { version = "0.9.2", features = ["stream"] }
lettre = "0.9.5" lettre = "0.9.5"
log = "0.4.14"
panorama-imap = { path = "imap", version = "0" } panorama-imap = { path = "imap", version = "0" }
parking_lot = "0.11.1" parking_lot = "0.11.1"
pin-project = "1.0.4" pin-project = "1.0.4"
@ -32,9 +34,6 @@ tokio-rustls = "0.22.0"
tokio-stream = { version = "0.1.3", features = ["sync"] } tokio-stream = { version = "0.1.3", features = ["sync"] }
tokio-util = { version = "0.6.3", features = ["full"] } tokio-util = { version = "0.6.3", features = ["full"] }
toml = "0.5.8" toml = "0.5.8"
tracing = "0.1.23"
tracing-appender = "0.1.2"
tracing-subscriber = "0.2.15"
webpki-roots = "0.21.0" webpki-roots = "0.21.0"
xdg = "2.2.0" xdg = "2.2.0"

View file

@ -5,6 +5,8 @@ panorama
Panorama is a terminal Personal Information Manager (PIM). Panorama is a terminal Personal Information Manager (PIM).
Status: **not done yet**
Goals: Goals:
- Never have to actually close the application. - Never have to actually close the application.

View file

@ -15,12 +15,12 @@ maintenance = { status = "passively-maintained" }
anyhow = "1.0.38" anyhow = "1.0.38"
derive_builder = "0.9.0" derive_builder = "0.9.0"
futures = "0.3.12" futures = "0.3.12"
log = "0.4.14"
nom = { version = "6.1.2", default-features = false, features = ["std"] } nom = { version = "6.1.2", default-features = false, features = ["std"] }
owning_ref = "0.4.1" owning_ref = "0.4.1"
parking_lot = "0.11.1" parking_lot = "0.11.1"
tokio = { version = "1.1.1", features = ["full"] } tokio = { version = "1.1.1", features = ["full"] }
tokio-rustls = "0.22.0" tokio-rustls = "0.22.0"
tracing = "0.1.23"
webpki-roots = "0.21.0" webpki-roots = "0.21.0"
[dev-dependencies] [dev-dependencies]

View file

@ -211,9 +211,16 @@ where
pin_mut!(fut2); pin_mut!(fut2);
match future::select(fut, fut2).await { match future::select(fut, fut2).await {
Either::Left((_, _)) => { Either::Left((res, _)) => {
debug!("got a new line"); res.context("read failed")?;
let (_, resp) = crate::parser::parse_response(next_line.as_bytes()).unwrap(); debug!("got a new line {:?}", next_line);
let (_, resp) = match crate::parser::parse_response(next_line.as_bytes()) {
Ok(v) => v,
Err(err) => {
debug!("shiet: {:?}", err);
continue;
}
};
let resp = Response::from(resp); let resp = Response::from(resp);
debug!("parsed as: {:?}", resp); debug!("parsed as: {:?}", resp);
let next_line = next_line.trim_end_matches('\n').trim_end_matches('\r'); let next_line = next_line.trim_end_matches('\n').trim_end_matches('\r');

View file

@ -5,7 +5,7 @@ extern crate derive_builder;
#[macro_use] #[macro_use]
extern crate futures; extern crate futures;
#[macro_use] #[macro_use]
extern crate tracing; extern crate log;
pub mod builders; pub mod builders;
pub mod client; pub mod client;

View file

@ -64,7 +64,7 @@ impl<'a> From<Response_<'a>> for Response {
information: information.map(str::to_owned), information: information.map(str::to_owned),
}, },
Expunge(n) => Response::Expunge(n), Expunge(n) => Response::Expunge(n),
Vanished {earlier, uids} => Response::Vanished{earlier, uids}, Vanished { earlier, uids } => Response::Vanished { earlier, uids },
_ => todo!("nyi: {:?}", b), _ => todo!("nyi: {:?}", b),
} }
} }
@ -132,10 +132,7 @@ pub enum UidSetMember {
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum AttributeValue { pub enum AttributeValue {}
}
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum MailboxDatum { pub enum MailboxDatum {}
}

View file

@ -60,10 +60,7 @@ pub enum ImapAuth {
/// Use plain username/password authentication /// Use plain username/password authentication
#[serde(rename = "plain")] #[serde(rename = "plain")]
#[allow(missing_docs)] #[allow(missing_docs)]
Plain { Plain { username: String, password: String },
username: String,
password: String,
}
} }
/// Describes when to perform the TLS handshake /// Describes when to perform the TLS handshake

View file

@ -14,7 +14,7 @@ extern crate format_bytes;
#[macro_use] #[macro_use]
extern crate serde; extern crate serde;
#[macro_use] #[macro_use]
extern crate tracing; extern crate log;
pub mod config; pub mod config;
pub mod mail; pub mod mail;

View file

@ -1,9 +1,11 @@
#[macro_use] #[macro_use]
extern crate tracing; extern crate log;
use std::fs::OpenOptions;
use std::path::PathBuf; use std::path::PathBuf;
use anyhow::Result; use anyhow::Result;
use fern::colors::{Color, ColoredLevelConfig};
use futures::future::TryFutureExt; use futures::future::TryFutureExt;
use panorama::{config::spawn_config_watcher_system, mail, report_err, ui}; use panorama::{config::spawn_config_watcher_system, mail, report_err, ui};
use structopt::StructOpt; use structopt::StructOpt;
@ -20,36 +22,29 @@ struct Opt {
#[tokio::main(flavor = "multi_thread")] #[tokio::main(flavor = "multi_thread")]
async fn main() -> Result<()> { async fn main() -> Result<()> {
// use panorama::config::*;
// let c = ImapConfig{
// server:String::from("ouais"),
// port: 1,
// tls: TlsMethod::Starttls,
// auth: ImapAuth::Plain{username:String::from("osu"), password:String::from("game")},
// };
// let s = toml::to_string(&c)?;
// println!("{}", s);
// panic!();
// parse command line arguments into options struct // parse command line arguments into options struct
let _opt = Opt::from_args(); let opt = Opt::from_args();
// print logs to file as directed by command line options let colors = ColoredLevelConfig::new()
use tracing_subscriber::filter::LevelFilter; .info(Color::Blue)
.debug(Color::BrightBlack)
let file = tracing_appender::rolling::daily("public", "lol"); .warn(Color::Yellow)
let (non_blocking, _guard) = tracing_appender::non_blocking(file); .error(Color::Red);
let mut logger = fern::Dispatch::new()
tracing_subscriber::fmt() .format(move |out, message, record| {
.with_max_level(LevelFilter::TRACE) out.finish(format_args!(
.with_writer(non_blocking) "{}[{}][{}] {}",
.with_thread_ids(true) chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"),
.init(); record.target(),
debug!("shiet"); colors.color(record.level()),
message
// TODO: debug ))
let x = span!(tracing::Level::WARN, "ouais"); })
let _y = x.enter(); .level(log::LevelFilter::Debug);
if let Some(log_file) = opt.log_file {
logger = logger.chain(fern::log_file(log_file)?);
}
logger.apply()?;
let _xdg = BaseDirectories::new()?; let _xdg = BaseDirectories::new()?;
let (_config_thread, config_update) = spawn_config_watcher_system()?; let (_config_thread, config_update) = spawn_config_watcher_system()?;

View file

@ -27,7 +27,6 @@ const FRAME: Duration = Duration::from_millis(20);
pub struct Rect(u16, u16, u16, u16); pub struct Rect(u16, u16, u16, u16);
/// UI entrypoint. /// UI entrypoint.
#[instrument(skip(w, exit))]
pub async fn run_ui(mut w: impl Write + Debug, exit: ExitSender) -> Result<()> { pub async fn run_ui(mut w: impl Write + Debug, exit: ExitSender) -> Result<()> {
execute!(w, cursor::Hide, terminal::EnterAlternateScreen)?; execute!(w, cursor::Hide, terminal::EnterAlternateScreen)?;
terminal::enable_raw_mode()?; terminal::enable_raw_mode()?;