diff --git a/Cargo.toml b/Cargo.toml index 2b0df9d4..f5b27fdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,22 +2,26 @@ name = "ping-viewer-next" version = "0.0.0" edition = "2021" +authors = ["Raul Victor Trombin "] +description = "This crate serves as the entry point for embedding applications using Rust on Blue Robotics's Ping devices family" +repository = "https://github.com/bluerobotics/ping-viewer-next" +license = "MIT" [dependencies] actix = "0.13.3" -actix-web = "4.6.0" +actix-web = "4.9.0" bluerobotics-ping = "0.3.0" actix-web-actors = "4.3.0" chrono = "0.4.38" -clap = {version = "4.5.4", features = ["derive"] } -lazy_static = "1.4.0" +clap = {version = "4.5.17", features = ["derive"] } +lazy_static = "1.5.0" mime_guess = "2.0.4" -paperclip = { version = "0.8.2" , features = ["actix4", "swagger-ui", "uuid"] } -serde = { version = "1.0.197", features = ["derive"] } -regex = "1.10.4" +paperclip = { version = "0.9.1" , features = ["actix4", "swagger-ui", "uuid"] } +serde = { version = "1.0.210", features = ["derive"] } +regex = "1.10.6" rust-embed = "8.4.0" -serde_json = "1.0.117" -tokio = { version = "1.37.0", features = ["full"] } +serde_json = "1.0.128" +tokio = { version = "1.40.0", features = ["full"] } tokio-serial = "5.4.4" tracing = { version = "0.1.40", features = ["log", "async-await"] } tracing-log = "0.2.0" @@ -25,10 +29,18 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tracing-appender = { git = "https://github.com/joaoantoniocardoso/tracing", branch = "tracing-appender-0.2.2-with-filename-suffix" } tracing-tracy = "0.11.0" udp-stream = "0.0.12" -uuid = { version = "1.8", features = ["serde"] } +uuid = { version = "1.10.0", features = ["serde"] } validator = "0.18.1" -thiserror = "1.0.61" +thiserror = "1.0.63" shellexpand = "3.1" [build-dependencies] -vergen-gix = { version = "1.0.0-beta.2", default-features = false, features = ["build", "cargo"] } +vergen-gix = { version = "1.0.1", default-features = false, features = ["build", "cargo"] } + +[lib] +name = "ping_viewer_next" +path = "src/lib.rs" + +[[bin]] +name = "ping-viewer-next" +path = "src/main.rs" diff --git a/src/cli/manager.rs b/src/cli/manager.rs index da8a2afb..93b10aa8 100644 --- a/src/cli/manager.rs +++ b/src/cli/manager.rs @@ -1,5 +1,6 @@ use clap; use clap::Parser; +use lazy_static::lazy_static; use std::sync::Arc; #[derive(Parser, Debug)] @@ -30,8 +31,8 @@ struct Args { enable_tracing_level_log_file: bool, /// Filter to show only own crate related logs - #[arg(long, default_value = "true")] - log_current_crate_only: bool, + #[arg(long, default_value = "false")] + log_include_all_dependencies: bool, /// Turns on the Tracy tool integration. #[arg(long)] @@ -73,8 +74,8 @@ pub fn is_tracy() -> bool { MANAGER.clap_matches.enable_tracy } -pub fn log_current_crate_only() -> bool { - MANAGER.clap_matches.log_current_crate_only +pub fn is_log_all_dependencies() -> bool { + MANAGER.clap_matches.log_include_all_dependencies } pub fn is_enable_auto_create() -> bool { diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 00000000..3b405655 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,12 @@ +pub mod cli; +pub mod device; +pub mod logger; +pub mod server; + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(tag = "module")] +pub enum ModuleType { + DeviceManager(device::manager::Request), +} diff --git a/src/logger/manager.rs b/src/logger/manager.rs index 17ab711d..ad51ca11 100644 --- a/src/logger/manager.rs +++ b/src/logger/manager.rs @@ -59,33 +59,35 @@ pub fn init() { // Configure the default subscriber match ( cli::manager::is_tracy(), - cli::manager::log_current_crate_only(), + cli::manager::is_log_all_dependencies(), ) { - (true, true) => { + (true, false) => { + let lib_name = env!("CARGO_PKG_NAME").replace('-', "_"); let subscriber = subscriber.with(EnvFilter::new(format!( - "{}={level}", - env!("CARGO_PKG_NAME").replace('-', "_") + "{lib_name}={level},lib{lib_name}={level}" ))); let tracy_layer = tracing_tracy::TracyLayer::default(); let subscriber = subscriber.with(tracy_layer); tracing::subscriber::set_global_default(subscriber) .expect("Unable to set a global subscriber"); } - (false, true) => { + (false, false) => { + let lib_name = env!("CARGO_PKG_NAME").replace('-', "_"); let subscriber = subscriber.with(EnvFilter::new(format!( - "{}={level}", - env!("CARGO_PKG_NAME").replace('-', "_") + "{lib_name}={level},lib{lib_name}={level}" ))); tracing::subscriber::set_global_default(subscriber) .expect("Unable to set a global subscriber"); } - (true, false) => { + (true, true) => { + let subscriber = subscriber.with(EnvFilter::new(level.to_string())); let tracy_layer = tracing_tracy::TracyLayer::default(); let subscriber = subscriber.with(tracy_layer); tracing::subscriber::set_global_default(subscriber) .expect("Unable to set a global subscriber"); } - (false, false) => { + (false, true) => { + let subscriber = subscriber.with(EnvFilter::new(level.to_string())); tracing::subscriber::set_global_default(subscriber) .expect("Unable to set a global subscriber"); } diff --git a/src/main.rs b/src/main.rs index 04c288bf..7c07f89d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,20 +1,6 @@ -use serde::{Deserialize, Serialize}; use tracing::info; -#[macro_use] -extern crate lazy_static; - -mod cli; -/// The Device module consists of two main modules: devices and manager. -mod device; -mod logger; -mod server; - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(tag = "module")] -pub enum ModuleType { - DeviceManager(device::manager::Request), -} +use ping_viewer_next::{cli, device, logger, server}; #[tokio::main] async fn main() {