diff --git a/.gitignore b/.gitignore index c1fc9e9..e60e326 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ target/ userdata/ +trinitrix.log # IDE stuff .idea diff --git a/Cargo.lock b/Cargo.lock index 93c16c6..cf1259c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,12 +85,6 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" -[[package]] -name = "arc-swap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" - [[package]] name = "arrayref" version = "0.3.7" @@ -379,6 +373,18 @@ dependencies = [ "inout", ] +[[package]] +name = "cli-log" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d2ab00dc4c82ec28af25ac085aecc11ffeabf353755715a3113a7aa044ca5cc" +dependencies = [ + "chrono", + "file-size", + "log", + "proc-status", +] + [[package]] name = "cloudabi" version = "0.0.3" @@ -571,17 +577,6 @@ dependencies = [ "const-oid", ] -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2 1.0.63", - "quote 1.0.29", - "syn 1.0.109", -] - [[package]] name = "derive_builder" version = "0.11.2" @@ -613,12 +608,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "destructure_traitobject" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c877555693c14d2f84191cfd3ad8582790fc52b5e2274b40b59cf5f5cea25c7" - [[package]] name = "digest" version = "0.9.0" @@ -738,6 +727,12 @@ dependencies = [ "instant", ] +[[package]] +name = "file-size" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9544f10105d33957765016b8a9baea7e689bf1f0f2f32c2fa2f568770c38d2b3" + [[package]] name = "fnv" version = "1.0.7" @@ -1057,12 +1052,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.27" @@ -1267,12 +1256,6 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -1294,41 +1277,6 @@ name = "log" version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" -dependencies = [ - "serde", -] - -[[package]] -name = "log-mdc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7" - -[[package]] -name = "log4rs" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36ca1786d9e79b8193a68d480a0907b612f109537115c6ff655a3a1967533fd" -dependencies = [ - "anyhow", - "arc-swap", - "chrono", - "derivative", - "fnv", - "humantime", - "libc", - "log", - "log-mdc", - "parking_lot 0.12.1", - "serde", - "serde-value", - "serde_json", - "serde_yaml", - "thiserror", - "thread-id", - "typemap-ors", - "winapi", -] [[package]] name = "lru" @@ -1584,16 +1532,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - [[package]] name = "num-traits" version = "0.2.15" @@ -1678,21 +1616,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "ordered-float" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87" -dependencies = [ - "num-traits", -] - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "parking_lot" version = "0.11.2" @@ -1863,6 +1786,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-status" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0e0c0ac915e7b76b47850ba4ffc377abde6c6ff9eeace61d0a89623db449712" +dependencies = [ + "thiserror", +] + [[package]] name = "prost" version = "0.11.9" @@ -2334,16 +2266,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-value" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" -dependencies = [ - "ordered-float", - "serde", -] - [[package]] name = "serde_bytes" version = "0.11.9" @@ -2387,18 +2309,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_yaml" -version = "0.8.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" -dependencies = [ - "indexmap 1.9.3", - "ryu", - "serde", - "yaml-rust", -] - [[package]] name = "sha2" version = "0.9.9" @@ -2423,15 +2333,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sharded-slab" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" -dependencies = [ - "lazy_static", -] - [[package]] name = "signal-hook" version = "0.3.15" @@ -2597,27 +2498,6 @@ dependencies = [ "syn 2.0.22", ] -[[package]] -name = "thread-id" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee93aa2b8331c0fec9091548843f2c90019571814057da3b783f9de09349d73" -dependencies = [ - "libc", - "redox_syscall 0.2.16", - "winapi", -] - -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - [[package]] name = "time" version = "0.1.45" @@ -2759,32 +2639,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" -dependencies = [ - "nu-ansi-term", - "sharded-slab", - "smallvec", - "thread_local", - "tracing-core", - "tracing-log", ] [[package]] @@ -2792,13 +2646,11 @@ name = "trinitrix" version = "0.1.0" dependencies = [ "anyhow", + "cli-log", "crossterm", - "log", - "log4rs", "matrix-sdk", "serde", "tokio", - "tracing-subscriber", "tui", "tui-textarea", ] @@ -2832,15 +2684,6 @@ dependencies = [ "tui", ] -[[package]] -name = "typemap-ors" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a68c24b707f02dd18f1e4ccceb9d49f2058c2fb86384ef9972592904d7a28867" -dependencies = [ - "unsafe-any-ors", -] - [[package]] name = "typenum" version = "1.16.0" @@ -2896,15 +2739,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "unsafe-any-ors" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a303d30665362d9680d7d91d78b23f5f899504d4f08b3c4cf08d055d87c0ad" -dependencies = [ - "destructure_traitobject", -] - [[package]] name = "url" version = "2.4.0" @@ -2944,12 +2778,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "vcpkg" version = "0.2.15" @@ -3297,15 +3125,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "zeroize" version = "1.3.0" diff --git a/Cargo.toml b/Cargo.toml index 66c18a6..143c4b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,5 @@ crossterm = "*" matrix-sdk = "0.6" anyhow = "1.0" tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } -tracing-subscriber = "0.3" serde = "1.0" -log = "0.4" -log4rs = "1.2" \ No newline at end of file +cli-log = "2.0" \ No newline at end of file diff --git a/src/accounts.rs b/src/accounts/mod.rs similarity index 99% rename from src/accounts.rs rename to src/accounts/mod.rs index 2ab3072..7f0a82a 100644 --- a/src/accounts.rs +++ b/src/accounts/mod.rs @@ -7,7 +7,7 @@ use matrix_sdk::{Client, Session}; use anyhow::{Error, Result}; use serde::{Deserialize, Serialize}; -use log::{error, warn, info}; +use cli_log::{error, warn, info}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Account { diff --git a/src/app/mod.rs b/src/app/mod.rs index 3ed81ac..f7acb06 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -4,7 +4,7 @@ use std::path::Path; use matrix_sdk::{Client}; use accounts::Account; use accounts::AccountsManager; -use log::{error, warn, info}; +use cli_log::{error, warn, info}; pub struct Message { pub author: String, diff --git a/src/main.rs b/src/main.rs index d0d7887..dbea59f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,33 +2,16 @@ mod ui; mod accounts; mod app; -use crate::ui::UI; -use matrix_sdk::ruma::exports::serde_json; -use tokio::time::{sleep, Duration}; -use std::{io, thread}; -use log::{error, warn, info, LevelFilter}; -use log4rs::append::file::FileAppender; -use log4rs::encode::pattern::PatternEncoder; -use log4rs::config::{Appender, Config, Root}; +use cli_log::{error, warn, info}; #[tokio::main] async fn main() -> anyhow::Result<()> { - let logfile = FileAppender::builder() - .encoder(Box::new(PatternEncoder::new("{l} - {m}\n"))) - .build("userdata/output.log")?; - - let config = Config::builder() - .appender(Appender::builder().build("logfile", Box::new(logfile))) - .build(Root::builder() - .appender("logfile") - .build(LevelFilter::Info))?; - - log4rs::init_config(config)?; + cli_log::init_cli_log!(); let mut app = app::App::new(); app.fill_test_data(); - let mut ui = UI::new(); + let mut ui = ui::UI::new(); if app.accounts_manager.num_accounts() == 0 { info!("No saved sessions found -> jumping into setup"); ui.setup(&mut app).await?; diff --git a/src/ui/mod.rs b/src/ui/mod.rs index e00d752..975d625 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -17,7 +17,7 @@ use tui::text::{Spans, Span, Text}; use tui::widgets::{Paragraph, Wrap}; use tui_textarea::{Input, Key, TextArea}; use tui_textarea::Key::Char; -use log::{error, warn, info}; +use cli_log::{error, warn, info}; #[derive(Clone, Copy)] enum SetupInputPosition {