summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2024-09-08 23:59:39 +0200
committerfxqnlr <[email protected]>2024-09-08 23:59:39 +0200
commit97896023cf5b8ac9a58baaba7d0571b0cc9ff8f7 (patch)
tree5a7840bb1905bd84ba95cca11b74762fd028f3d0 /src/main.rs
parent9a34651063029394845a3e18fe7afd5b7c4db777 (diff)
downloadarbs-97896023cf5b8ac9a58baaba7d0571b0cc9ff8f7.tar
arbs-97896023cf5b8ac9a58baaba7d0571b0cc9ff8f7.tar.gz
arbs-97896023cf5b8ac9a58baaba7d0571b0cc9ff8f7.zip
add logging
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs
index e67e535..1284e0c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,8 @@
1use backup::Backup; 1use backup::Backup;
2use config::Config; 2use config::Config;
3use packages::{pacman::Pacman, PackageManager}; 3use packages::{pacman::Pacman, PackageManager};
4use tracing::{debug, info, level_filters::LevelFilter};
5use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
4 6
5mod backup; 7mod backup;
6mod config; 8mod config;
@@ -11,30 +13,39 @@ mod pathinfo;
11fn main() -> color_eyre::Result<()> { 13fn main() -> color_eyre::Result<()> {
12 color_eyre::install()?; 14 color_eyre::install()?;
13 15
16 let file_appender = tracing_appender::rolling::never("./", "arps.log");
17 let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
18
19 tracing_subscriber::registry()
20 .with(
21 fmt::layer()
22 .with_writer(non_blocking)
23 .with_file(false)
24 .with_ansi(false)
25 .without_time(),
26 )
27 .with(fmt::layer().with_file(false).without_time())
28 .with(
29 EnvFilter::builder()
30 .with_default_directive(LevelFilter::INFO.into())
31 .from_env_lossy(),
32 )
33 .init();
34 debug!("logging initialized");
35
14 let mut cfg = Config::load()?; 36 let mut cfg = Config::load()?;
15 cfg.user.push("fx".to_string()); 37 cfg.user.push("fx".to_string());
16 cfg.directories.push("~/.config/nvim".to_string()); 38 cfg.directories.push("~/.config/nvim".to_string());
17 // cfg.directories.push("~/.config/hypr".to_string());
18 cfg.root = "./backup".to_string(); 39 cfg.root = "./backup".to_string();
19 // cfg.root = "./backup-test".to_string();
20 // cfg.directories.push("u:/code/proj/fxbaup/backup-test-dir".to_string());
21 40
22 let pacman = Pacman; 41 let pacman = Pacman;
23 let pkgs = pacman.get_installed()?; 42 let pkgs = pacman.get_installed()?;
24 43 let backup = Backup::create(&cfg, pkgs);
25 let backup = Backup::create(&cfg, pkgs)?; 44 // info!(?backup);
26 // println!("{backup:#?}"); 45 // pacman.install(vec![Package {
27 46 // id: "lapce".to_string(),
28 backup.save(&cfg)?; 47 // version: "0.4.2-1".to_string(),
29 48 // explicit: true,
30 // PathInfo::compare_to_last_modified(&cfg, &LocationRoot::User("fx".to_string()), "code/proj/fxbaub/backup-test-dir/size.txt")?; 49 // }])?;
31 // PathInfo::compare_to_last_modified(&cfg, &LocationRoot::User("fx".to_string()), "code/proj/fxbaub/backup-test-dir/content.txt")?;
32
33 // let index = Backup::get_index(&cfg, None)?;
34
35 // println!("{index:#?}");
36
37 // let fi = FileInfo::new("~/.config/nvim", &cfg)?;
38 // println!("{:?}", fi.get_absolute_path());
39 Ok(()) 50 Ok(())
40} 51}