Switch to fern logger
It was annoying to get debug logs for modules that aren't even oursmaster
parent
856cf0968d
commit
eef33cdf0c
|
@ -23,6 +23,15 @@ version = "0.1.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd"
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-channel"
|
||||
version = "1.6.1"
|
||||
|
@ -267,14 +276,16 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.19"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
|
||||
checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
"time 0.1.44",
|
||||
"wasm-bindgen",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -447,6 +458,15 @@ dependencies = [
|
|||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fern"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bdd7b0849075e79ee9a1836df22c717d1eba30451796fdc631b04565dd11e2a"
|
||||
dependencies = [
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
|
@ -673,6 +693,19 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.3"
|
||||
|
@ -759,9 +792,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.125"
|
||||
version = "0.2.134"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
|
||||
checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb"
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
|
@ -2032,7 +2065,9 @@ dependencies = [
|
|||
"async-native-tls",
|
||||
"async-std",
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"derive-getters",
|
||||
"fern",
|
||||
"futures",
|
||||
"futures-timer",
|
||||
"itertools",
|
||||
|
|
|
@ -18,6 +18,8 @@ simplelog = "0.12.0"
|
|||
async-trait = "0.1.53"
|
||||
scraper = "0.13.0"
|
||||
itertools = "0.10.4"
|
||||
fern = "0.6.1"
|
||||
chrono = "0.4.22"
|
||||
|
||||
# For annoying reasons, we must pin exactly the same versions as async-imap if we want to use
|
||||
# their types.
|
||||
|
|
23
src/main.rs
23
src/main.rs
|
@ -3,8 +3,6 @@ extern crate log;
|
|||
|
||||
use futures::{stream::StreamExt, Future};
|
||||
use log::LevelFilter;
|
||||
use simplelog::{Config as LogConfig, SimpleLogger};
|
||||
use std::collections::HashMap;
|
||||
use std::{fs::File, sync::Arc};
|
||||
use tokio::runtime::Runtime;
|
||||
use ynabifier::parse::{Transaction, TransactionEmailParser};
|
||||
|
@ -16,7 +14,7 @@ use ynabifier::{
|
|||
};
|
||||
|
||||
fn main() {
|
||||
SimpleLogger::init(LevelFilter::Debug, LogConfig::default()).expect("setup failed");
|
||||
setup_logger().expect("failed to seutp logger");
|
||||
let config_file = File::open("config.yml").expect("failed to open config file");
|
||||
let config =
|
||||
serde_yaml::from_reader::<_, Config>(config_file).expect("failed to parse config file");
|
||||
|
@ -50,6 +48,25 @@ fn main() {
|
|||
});
|
||||
}
|
||||
|
||||
fn setup_logger() -> Result<(), fern::InitError> {
|
||||
fern::Dispatch::new()
|
||||
.format(|out, message, record| {
|
||||
out.finish(format_args!(
|
||||
"{} [{}] [{}] {}",
|
||||
chrono::Local::now().format("%Y-%m-%dT%H:%M:%S"),
|
||||
record.level(),
|
||||
record.target(),
|
||||
message
|
||||
))
|
||||
})
|
||||
.level(LevelFilter::Info)
|
||||
.level_for("ynabifier", LevelFilter::Debug)
|
||||
.chain(std::io::stderr())
|
||||
.apply()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn try_parse_email<'a, I>(parser_iter: I, msg: &Message) -> Option<Transaction>
|
||||
where
|
||||
I: Iterator<Item = &'a (&'a str, Box<dyn TransactionEmailParser>)>,
|
||||
|
|
Loading…
Reference in New Issue