diff --git a/Cargo.lock b/Cargo.lock index 7d6d220..edf5c84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -485,6 +485,15 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" +[[package]] +name = "crossbeam-channel" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-queue" version = "0.3.11" @@ -2204,9 +2213,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.33" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3cc72858054fcff6d7dea32df2aeaee6a7c24227366d7ea429aada2f26b16ad" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno", @@ -2260,9 +2269,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" +checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" [[package]] name = "rustls-webpki" @@ -3264,6 +3273,18 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror", + "time", + "tracing-subscriber", +] + [[package]] name = "tracing-attributes" version = "0.1.27" @@ -3322,11 +3343,25 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "twba-backup-config" -version = "0.1.3" -source = "git+https://github.com/OMGeeky/backup_config.git#88645945830d3076478827503fef43541a2f047e" +version = "0.1.6" +source = "git+https://github.com/OMGeeky/backup_config.git#60092672b4b45667ef21073b3c43c062715ce486" dependencies = [ "confique", "serde", + "shellexpand", + "tracing", +] + +[[package]] +name = "twba-common" +version = "0.1.0" +source = "git+https://github.com/OMGeeky/twba.common.git#a3499ea8bf573db344ec8269782ecd576f3291b5" +dependencies = [ + "tracing", + "tracing-appender", + "tracing-subscriber", + "twba-backup-config", + "twba-local-db", ] [[package]] @@ -3376,6 +3411,7 @@ dependencies = [ "tracing", "tracing-subscriber", "twba-backup-config", + "twba-common", "twba-local-db", "twba-reqwest-backoff", "yup-oauth2", diff --git a/Cargo.toml b/Cargo.toml index 19b9a2d..5c4652b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ edition = "2021" twba-backup-config = { version = "0.1.2", git = "https://github.com/OMGeeky/backup_config.git" } twba-local-db = { version = "0.2", git = "https://github.com/OMGeeky/twitch_backup.local_db.git" } twba-reqwest-backoff = { version = "0.1", git = "https://github.com/OMGeeky/twba_reqwest_backoff.git" } +twba-common = { version = "0.1", git = "https://github.com/OMGeeky/twba.common.git" } tracing-subscriber = "0.3" diff --git a/src/main.rs b/src/main.rs index 299a54e..fc5aace 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ #![allow(unused)] use lazy_static::lazy_static; use twba_backup_config::prelude::*; +use twba_common::{get_config, init_tracing}; use prelude::*; @@ -9,32 +10,11 @@ pub mod errors; pub mod prelude; lazy_static! { - pub(crate) static ref CONF: Conf = Conf::builder() - .env() - .file( - std::env::var("TWBA_CONFIG") - .map(|v| { - info!("using '{}' as primary config source after env", v); - v - }) - .unwrap_or_else(|x| { - warn!("could not get config location from env"); - "./settings.toml".to_string() - }) - ) - .file("./settings.toml") - .file(shellexpand::tilde("~/twba/config.toml").into_owned()) - .file(std::env::var("TWBA_CONFIG").unwrap_or_else(|_| "~/twba/config.toml".to_string())) - .load() - .map_err(|e| UploaderError::LoadConfig(e.into())) - .expect("Failed to load config"); + pub(crate) static ref CONF: Conf = get_config(); } #[tokio::main] async fn main() -> Result<()> { - tracing_subscriber::fmt() - .with_max_level(tracing::Level::INFO) - .with_env_filter("warn,twba_uploader=trace") - .init(); + init_tracing("twba_uploader"); let args = std::env::args().collect::>(); let presentation_mode = args.len() > 1; info!("Hello, world!");