From e3b700529ff5a6ff730ad8009b56ae085ad95735 Mon Sep 17 00:00:00 2001 From: SyntheticBird45 Date: Wed, 19 Jun 2024 11:29:21 +0200 Subject: [PATCH] added file appender --- Cargo.lock | 65 +++++++++++++++++++++++++++ p2p/cuprate-p2p/Cargo.toml | 1 + p2p/cuprate-p2p/src/bin/test_init.rs | 7 ++- p2p_store | Bin 186834 -> 185538 bytes 4 files changed, 72 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index cc9c10d1..39a151cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -623,6 +623,7 @@ dependencies = [ "tokio-util", "tower", "tracing", + "tracing-appender", "tracing-subscriber", ] @@ -743,6 +744,15 @@ dependencies = [ name = "database" version = "0.0.0" +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "diff" version = "0.1.13" @@ -1578,6 +1588,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" version = "0.2.18" @@ -1785,6 +1801,12 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2431,6 +2453,37 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -2601,6 +2654,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" diff --git a/p2p/cuprate-p2p/Cargo.toml b/p2p/cuprate-p2p/Cargo.toml index 47362bb6..7125217d 100644 --- a/p2p/cuprate-p2p/Cargo.toml +++ b/p2p/cuprate-p2p/Cargo.toml @@ -38,6 +38,7 @@ hex = { workspace = true, features = ["std"] } tracing = { workspace = true, features = ["std", "attributes"] } tracing-subscriber = "0.3.18" +tracing-appender = "0.2.3" [dev-dependencies] cuprate-test-utils = { path = "../../test-utils" } diff --git a/p2p/cuprate-p2p/src/bin/test_init.rs b/p2p/cuprate-p2p/src/bin/test_init.rs index 8f73e771..dcfa1574 100644 --- a/p2p/cuprate-p2p/src/bin/test_init.rs +++ b/p2p/cuprate-p2p/src/bin/test_init.rs @@ -21,6 +21,7 @@ use monero_p2p::{PeerRequest, PeerResponse}; use monero_wire::admin::TimedSyncResponse; use rayon::iter::IntoParallelIterator; use rayon::prelude::*; +use tracing_appender::rolling::{RollingFileAppender, Rotation}; use std::collections::HashMap; use std::future::Future; use std::path::PathBuf; @@ -192,9 +193,13 @@ async fn main() { .await .unwrap(); + let file_appender = RollingFileAppender::new(Rotation::NEVER, "/var/log/cuprate/", "cuprate.log"); + let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender); + tracing_subscriber::fmt() - .with_max_level(Level::DEBUG) + .with_max_level(Level::INFO) .with_timer(Uptime::default()) + .with_writer(non_blocking) .init(); let config = P2PConfig:: { diff --git a/p2p_store b/p2p_store index e1d2a341ec4c7b6b7ae370bbd1564def25f539a5..d12052f48605a30d589a7cc0f2f766c88791f3a6 100644 GIT binary patch delta 445 zcmWlUK}b|#6otEYUe;qYZDKZtZ%T8-V!|{Rih>KtCMk$ai6A7Tka$y%5Og7mXszNY zKXO(r%*7x!3waF>!eFdmAOp)Oohit)O@f<1vV}$W-+i2W?z!i#dcoIoL9!R9Jft>k z%WDdqEm3D|OHD+!)L+}0eR6_SQ^NA*PmYqB5J$YKw?xefWa}15EeXuje>2r_@jPvL zZmPH__b+q>)Lnti_@#*INmP3m`?msA=M5*mG$55{%Nuz1vKGslF2CCaM zS{Jf&-KPxm`@$`(>{F$;xfeC?OAliEw~OEk`6;H!B0SD>)W2!cTf()1sI5VIa17gd zuE8gZM$ow?b05R;UoyGO<77eYF~FHowJU4uhM z;pqKrm>)%u(k<>a@{WO+#(`%3ZDL#FR6GBQlPQt>3gEl8p3)BG=nWo;OG!!02= KVnFUQ-}n!mkhQV^ delta 1142 zcmYjPdr(wW80Xx*1FXPBaH-vE+}&k)xKOe@R$xGE1r7?qP@ohBqVkYI@dV zEe1_(m6c zr_`gdQUw(L{crBz;o{b^p1$Z1IEU7^vw}gB=|mSt9ns@MK1Akg z-BrLOb&Vh6VfXa-7xMDO)56ifdr}1+@jbvpJFmb;h1GEZ%X}s%oQPGjg)`q}x1*xwA~;(Hsw;g!rNK^o!p znh_h=91(_rA3>B!ASFN%+qY59!^wG1{oB5l{%18#Re-Qq*=Tyl9^#I+=vdIp>Cz{- z_{RX)XV3H#g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