log: New crate for logger implementations
Move logging-related module `radicle::logging` into its own crate. While at it, remove the "logger" feature flag from `radicle`. Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.dev>
This commit is contained in:
parent
f22811e015
commit
caee776c38
|
|
@ -2981,8 +2981,6 @@ dependencies = [
|
||||||
"amplify",
|
"amplify",
|
||||||
"base64 0.21.7",
|
"base64 0.21.7",
|
||||||
"bytesize",
|
"bytesize",
|
||||||
"chrono",
|
|
||||||
"colored",
|
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"cyphernet",
|
"cyphernet",
|
||||||
"dunce",
|
"dunce",
|
||||||
|
|
@ -3038,6 +3036,7 @@ dependencies = [
|
||||||
"radicle-cob",
|
"radicle-cob",
|
||||||
"radicle-crypto",
|
"radicle-crypto",
|
||||||
"radicle-localtime",
|
"radicle-localtime",
|
||||||
|
"radicle-log",
|
||||||
"radicle-node",
|
"radicle-node",
|
||||||
"radicle-surf",
|
"radicle-surf",
|
||||||
"radicle-term",
|
"radicle-term",
|
||||||
|
|
@ -3073,6 +3072,8 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"radicle",
|
"radicle",
|
||||||
|
"radicle-log",
|
||||||
|
"radicle-term",
|
||||||
"shlex",
|
"shlex",
|
||||||
"snapbox",
|
"snapbox",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
|
|
@ -3208,6 +3209,18 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "radicle-log"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"colored",
|
||||||
|
"log",
|
||||||
|
"radicle-localtime",
|
||||||
|
"radicle-term",
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "radicle-node"
|
name = "radicle-node"
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
|
|
@ -3228,6 +3241,7 @@ dependencies = [
|
||||||
"radicle-crypto",
|
"radicle-crypto",
|
||||||
"radicle-fetch",
|
"radicle-fetch",
|
||||||
"radicle-localtime",
|
"radicle-localtime",
|
||||||
|
"radicle-log",
|
||||||
"radicle-protocol",
|
"radicle-protocol",
|
||||||
"radicle-signals",
|
"radicle-signals",
|
||||||
"radicle-systemd",
|
"radicle-systemd",
|
||||||
|
|
@ -3289,6 +3303,7 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"radicle",
|
"radicle",
|
||||||
"radicle-cli",
|
"radicle-cli",
|
||||||
|
"radicle-log",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ radicle-fetch = { version = "0.20", path = "crates/radicle-fetch" }
|
||||||
radicle-git-metadata = { version = "0.2.0", path = "crates/radicle-git-metadata", default-features = false }
|
radicle-git-metadata = { version = "0.2.0", path = "crates/radicle-git-metadata", default-features = false }
|
||||||
radicle-git-ref-format = { version = "0.1.0", path = "crates/radicle-git-ref-format", default-features = false }
|
radicle-git-ref-format = { version = "0.1.0", path = "crates/radicle-git-ref-format", default-features = false }
|
||||||
radicle-localtime = { version = "0.1", path = "crates/radicle-localtime" }
|
radicle-localtime = { version = "0.1", path = "crates/radicle-localtime" }
|
||||||
|
radicle-log = { version = "0.1", path = "crates/radicle-log" }
|
||||||
radicle-node = { version = "0.20", path = "crates/radicle-node" }
|
radicle-node = { version = "0.20", path = "crates/radicle-node" }
|
||||||
radicle-oid = { version = "0.2.0", path = "crates/radicle-oid", default-features = false }
|
radicle-oid = { version = "0.2.0", path = "crates/radicle-oid", default-features = false }
|
||||||
radicle-protocol = { version = "0.8", path = "crates/radicle-protocol" }
|
radicle-protocol = { version = "0.8", path = "crates/radicle-protocol" }
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,9 @@ rust-version.workspace = true
|
||||||
escargot = "0.5.7"
|
escargot = "0.5.7"
|
||||||
log = { workspace = true, features = ["std"] }
|
log = { workspace = true, features = ["std"] }
|
||||||
pretty_assertions = { workspace = true }
|
pretty_assertions = { workspace = true }
|
||||||
radicle = { workspace = true, features = ["logger", "test"]}
|
radicle = { workspace = true, features = ["test"] }
|
||||||
|
radicle-log = { workspace = true, features = ["test"] }
|
||||||
|
radicle-term = { workspace = true }
|
||||||
snapbox = { workspace = true }
|
snapbox = { workspace = true }
|
||||||
thiserror = { workspace = true, default-features = true }
|
thiserror = { workspace = true, default-features = true }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,8 +186,11 @@ impl TestFormula {
|
||||||
// We don't need to re-build every time the `build` function is called. Once is enough.
|
// We don't need to re-build every time the `build` function is called. Once is enough.
|
||||||
BUILD.call_once(|| {
|
BUILD.call_once(|| {
|
||||||
use escargot::format::Message;
|
use escargot::format::Message;
|
||||||
use radicle::logger::env_level;
|
use radicle_log::env_level;
|
||||||
use radicle::logger::test::Logger;
|
use radicle_log::test::Logger;
|
||||||
|
use radicle_term::Paint;
|
||||||
|
|
||||||
|
Paint::force(true);
|
||||||
|
|
||||||
let level = env_level().unwrap_or(log::Level::Debug);
|
let level = env_level().unwrap_or(log::Level::Debug);
|
||||||
let logger = Box::new(Logger::new(level));
|
let logger = Box::new(Logger::new(level));
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,13 @@ humantime.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
log = { workspace = true, features = ["std"] }
|
log = { workspace = true, features = ["std"] }
|
||||||
nonempty = { workspace = true }
|
nonempty = { workspace = true }
|
||||||
radicle = { workspace = true, features = ["logger", "schemars"] }
|
radicle = { workspace = true, features = ["schemars"] }
|
||||||
radicle-cob = { workspace = true }
|
radicle-cob = { workspace = true }
|
||||||
radicle-crypto = { workspace = true }
|
radicle-crypto = { workspace = true }
|
||||||
radicle-localtime = { workspace = true }
|
radicle-localtime = { workspace = true }
|
||||||
radicle-surf = { workspace = true }
|
radicle-surf = { workspace = true }
|
||||||
radicle-term = { workspace = true }
|
radicle-term = { workspace = true }
|
||||||
|
radicle-log = { workspace = true }
|
||||||
schemars = { workspace = true }
|
schemars = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
|
|
@ -69,6 +70,7 @@ radicle = { workspace = true, features = ["test"] }
|
||||||
radicle-cli-test = { workspace = true }
|
radicle-cli-test = { workspace = true }
|
||||||
radicle-localtime = { workspace = true }
|
radicle-localtime = { workspace = true }
|
||||||
radicle-node = { workspace = true, features = ["test"] }
|
radicle-node = { workspace = true, features = ["test"] }
|
||||||
|
radicle-log = { workspace = true, features = ["test"] }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
|
||||||
|
|
@ -137,8 +137,8 @@ fn main() {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(lvl) = radicle::logger::env_level() {
|
if let Some(lvl) = radicle_log::env_level() {
|
||||||
let logger = Box::new(radicle::logger::Logger::new());
|
let logger = Box::new(radicle_log::Logger::new());
|
||||||
log::set_boxed_logger(logger).expect("no other logger should have been set already");
|
log::set_boxed_logger(logger).expect("no other logger should have been set already");
|
||||||
log::set_max_level(lvl.to_level_filter());
|
log::set_max_level(lvl.to_level_filter());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use radicle::prelude::RepoId;
|
||||||
use radicle::profile::Home;
|
use radicle::profile::Home;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use radicle_node::test::logger;
|
use radicle_log::test::Logger;
|
||||||
|
|
||||||
mod util;
|
mod util;
|
||||||
use util::environment::Environment;
|
use util::environment::Environment;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
[package]
|
||||||
|
name = "radicle-log"
|
||||||
|
description = "Radicle loggers"
|
||||||
|
homepage.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
version = "0.1.0"
|
||||||
|
edition.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
|
||||||
|
[features]
|
||||||
|
test = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
chrono = { workspace = true, features = ["clock"] }
|
||||||
|
colored = { workspace = true }
|
||||||
|
radicle-localtime = { workspace = true, features = ["serde"] }
|
||||||
|
log = { version = "0.4", features = ["std"] }
|
||||||
|
radicle-term = { workspace = true }
|
||||||
|
regex = "1"
|
||||||
|
|
@ -5,8 +5,7 @@
|
||||||
#[cfg(feature = "test")]
|
#[cfg(feature = "test")]
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
use std::io;
|
use std::io::{self, Write};
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use colored::*;
|
use colored::*;
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use localtime::LocalTime;
|
|
||||||
use log::*;
|
use log::*;
|
||||||
|
use radicle_localtime::LocalTime;
|
||||||
|
|
||||||
pub struct Logger {
|
pub struct Logger {
|
||||||
level: Level,
|
level: Level,
|
||||||
|
|
@ -28,11 +28,12 @@ lexopt = { workspace = true }
|
||||||
log = { workspace = true, features = ["kv", "std"] }
|
log = { workspace = true, features = ["kv", "std"] }
|
||||||
mio = { version = "1", features = ["net", "os-poll"] }
|
mio = { version = "1", features = ["net", "os-poll"] }
|
||||||
qcheck = { workspace = true, optional = true }
|
qcheck = { workspace = true, optional = true }
|
||||||
radicle = { workspace = true, features = ["logger"] }
|
radicle = { workspace = true }
|
||||||
radicle-fetch = { workspace = true }
|
radicle-fetch = { workspace = true }
|
||||||
radicle-localtime = { workspace = true }
|
radicle-localtime = { workspace = true }
|
||||||
radicle-protocol = { workspace = true }
|
radicle-protocol = { workspace = true }
|
||||||
radicle-signals = { workspace = true }
|
radicle-signals = { workspace = true }
|
||||||
|
radicle-log = { workspace = true }
|
||||||
serde = { workspace = true, features = ["derive"] }
|
serde = { workspace = true, features = ["derive"] }
|
||||||
serde_json = { workspace = true, features = ["preserve_order"] }
|
serde_json = { workspace = true, features = ["preserve_order"] }
|
||||||
snapbox = { workspace = true, optional = true }
|
snapbox = { workspace = true, optional = true }
|
||||||
|
|
@ -53,6 +54,7 @@ mio = { version = "1", features = ["os-ext"] }
|
||||||
qcheck = { workspace = true }
|
qcheck = { workspace = true }
|
||||||
qcheck-macros = { workspace = true }
|
qcheck-macros = { workspace = true }
|
||||||
radicle = { workspace = true, features = ["test"] }
|
radicle = { workspace = true, features = ["test"] }
|
||||||
|
radicle-log = { workspace = true, features = ["test"] }
|
||||||
radicle-protocol = { workspace = true, features = ["test"] }
|
radicle-protocol = { workspace = true, features = ["test"] }
|
||||||
radicle-crypto = { workspace = true, features = ["test", "cyphernet"] }
|
radicle-crypto = { workspace = true, features = ["test", "cyphernet"] }
|
||||||
snapbox = { workspace = true }
|
snapbox = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -401,7 +401,7 @@ fn initialize_logging(options: &LogOptions) -> Result<(), Box<dyn std::error::Er
|
||||||
const SYSLOG_IDENTIFIER: &str = "radicle-node";
|
const SYSLOG_IDENTIFIER: &str = "radicle-node";
|
||||||
logger::<&str, &str, _>(SYSLOG_IDENTIFIER.to_string(), []).map_err(Box::new)?
|
logger::<&str, &str, _>(SYSLOG_IDENTIFIER.to_string(), []).map_err(Box::new)?
|
||||||
}
|
}
|
||||||
Logger::Radicle => Box::new(radicle::logger::Logger::new()),
|
Logger::Radicle => Box::new(radicle_log::Logger::new()),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@ pub mod peer;
|
||||||
pub mod simulator;
|
pub mod simulator;
|
||||||
|
|
||||||
pub use radicle::assert_matches;
|
pub use radicle::assert_matches;
|
||||||
pub use radicle::logger::test as logger;
|
|
||||||
pub use radicle::test::*;
|
pub use radicle::test::*;
|
||||||
|
pub use radicle_log::test as logger;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ fastrand = { workspace = true }
|
||||||
log = { workspace = true, features = ["std"] }
|
log = { workspace = true, features = ["std"] }
|
||||||
nonempty = { workspace = true, features = ["serialize"] }
|
nonempty = { workspace = true, features = ["serialize"] }
|
||||||
qcheck = { workspace = true, optional = true }
|
qcheck = { workspace = true, optional = true }
|
||||||
radicle = { workspace = true, features = ["logger"] }
|
radicle = { workspace = true }
|
||||||
radicle-core = { workspace = true }
|
radicle-core = { workspace = true }
|
||||||
radicle-fetch = { workspace = true }
|
radicle-fetch = { workspace = true }
|
||||||
radicle-localtime = { workspace = true }
|
radicle-localtime = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,5 @@ dunce = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
radicle = { workspace = true }
|
radicle = { workspace = true }
|
||||||
radicle-cli = { workspace = true }
|
radicle-cli = { workspace = true }
|
||||||
|
radicle-log = { workspace = true }
|
||||||
thiserror = { workspace = true, default-features = true }
|
thiserror = { workspace = true, default-features = true }
|
||||||
|
|
@ -51,8 +51,8 @@ const VERSION: Version = Version {
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut args = env::args();
|
let mut args = env::args();
|
||||||
|
|
||||||
if let Some(lvl) = radicle::logger::env_level() {
|
if let Some(lvl) = radicle_log::env_level() {
|
||||||
let logger = radicle::logger::StderrLogger::new();
|
let logger = radicle_log::StderrLogger::new();
|
||||||
log::set_boxed_logger(Box::new(logger))
|
log::set_boxed_logger(Box::new(logger))
|
||||||
.expect("no other logger should have been set already");
|
.expect("no other logger should have been set already");
|
||||||
log::set_max_level(lvl.to_level_filter());
|
log::set_max_level(lvl.to_level_filter());
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ default = []
|
||||||
gix = ["radicle-oid/gix"]
|
gix = ["radicle-oid/gix"]
|
||||||
i2p = ["cyphernet/i2p"]
|
i2p = ["cyphernet/i2p"]
|
||||||
test = ["tempfile", "qcheck", "radicle-crypto/test", "radicle-cob/test"]
|
test = ["tempfile", "qcheck", "radicle-crypto/test", "radicle-cob/test"]
|
||||||
logger = ["colored", "chrono"]
|
|
||||||
qcheck = [
|
qcheck = [
|
||||||
"radicle-core/qcheck",
|
"radicle-core/qcheck",
|
||||||
"radicle-oid/qcheck",
|
"radicle-oid/qcheck",
|
||||||
|
|
@ -34,8 +33,6 @@ tor = ["cyphernet/tor"]
|
||||||
amplify = { workspace = true, features = ["std"] }
|
amplify = { workspace = true, features = ["std"] }
|
||||||
base64 = "0.21.3"
|
base64 = "0.21.3"
|
||||||
bytesize = { version = "2", features = ["serde"] }
|
bytesize = { version = "2", features = ["serde"] }
|
||||||
chrono = { workspace = true, features = ["clock"], optional = true }
|
|
||||||
colored = { workspace = true, optional = true }
|
|
||||||
crossbeam-channel = { workspace = true }
|
crossbeam-channel = { workspace = true }
|
||||||
cyphernet = { workspace = true, features = ["dns", "p2p-ed25519"] }
|
cyphernet = { workspace = true, features = ["dns", "p2p-ed25519"] }
|
||||||
dunce = { workspace = true }
|
dunce = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@ pub mod explorer;
|
||||||
pub mod git;
|
pub mod git;
|
||||||
pub mod identity;
|
pub mod identity;
|
||||||
pub mod io;
|
pub mod io;
|
||||||
#[cfg(feature = "logger")]
|
|
||||||
pub mod logger;
|
|
||||||
pub mod node;
|
pub mod node;
|
||||||
pub mod profile;
|
pub mod profile;
|
||||||
pub mod rad;
|
pub mod rad;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue