debug suff

This commit is contained in:
Erica Marigold 2023-06-01 20:21:41 +05:30
parent 90679afadb
commit 932bcc9417
No known key found for this signature in database
GPG key ID: DA2C44572707FB1C
8 changed files with 284 additions and 108 deletions

160
Cargo.lock generated
View file

@ -56,17 +56,6 @@ dependencies = [
"opaque-debug", "opaque-debug",
] ]
[[package]]
name = "ahash"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
dependencies = [
"cfg-if 1.0.0",
"once_cell",
"version_check",
]
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.5" version = "0.1.5"
@ -82,14 +71,6 @@ version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
[[package]]
name = "anymap"
version = "0.1.0"
source = "git+https://github.com/CompeyDev/signals-rs.git?rev=8a650a1#8a650a19813fce0dbada0e6238b9cfe7cd4660c5"
dependencies = [
"hashbrown",
]
[[package]] [[package]]
name = "arrayref" name = "arrayref"
version = "0.3.7" version = "0.3.7"
@ -321,7 +302,6 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
name = "backend" name = "backend"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anymap",
"framework", "framework",
"rand 0.8.5", "rand 0.8.5",
"serde", "serde",
@ -653,10 +633,11 @@ dependencies = [
name = "framework" name = "framework"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anymap",
"colored", "colored",
"serde", "serde",
"tide", "tide",
"tide-tracing",
"tracing",
] ]
[[package]] [[package]]
@ -780,15 +761,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash",
]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.19" version = "0.1.19"
@ -1021,6 +993,16 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[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]] [[package]]
name = "num-integer" name = "num-integer"
version = "0.1.45" version = "0.1.45"
@ -1052,9 +1034,9 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.17.1" version = "1.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b"
[[package]] [[package]]
name = "opaque-debug" name = "opaque-debug"
@ -1062,6 +1044,12 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]] [[package]]
name = "parking" name = "parking"
version = "2.1.0" version = "2.1.0"
@ -1318,7 +1306,10 @@ name = "sealz"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"backend", "backend",
"once_cell",
"tokio", "tokio",
"tracing",
"tracing-subscriber",
] ]
[[package]] [[package]]
@ -1427,6 +1418,15 @@ dependencies = [
"opaque-debug", "opaque-debug",
] ]
[[package]]
name = "sharded-slab"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
dependencies = [
"lazy_static",
]
[[package]] [[package]]
name = "signal-hook" name = "signal-hook"
version = "0.3.15" version = "0.3.15"
@ -1654,6 +1654,16 @@ dependencies = [
"syn 2.0.18", "syn 2.0.18",
] ]
[[package]]
name = "thread_local"
version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
dependencies = [
"cfg-if 1.0.0",
"once_cell",
]
[[package]] [[package]]
name = "tide" name = "tide"
version = "0.16.0" version = "0.16.0"
@ -1677,6 +1687,18 @@ dependencies = [
"serde_json", "serde_json",
] ]
[[package]]
name = "tide-tracing"
version = "0.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "500f567f8c4d65210e6a7c9978661cc7ad6be1dc97e32c3e88bf8f0f0599c23d"
dependencies = [
"async-trait",
"tide",
"tracing",
"tracing-futures",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.45" version = "0.1.45"
@ -1771,6 +1793,74 @@ dependencies = [
"syn 2.0.18", "syn 2.0.18",
] ]
[[package]]
name = "tracing"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if 1.0.0",
"pin-project-lite 0.2.9",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.18",
]
[[package]]
name = "tracing-core"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-futures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
dependencies = [
"pin-project",
"tracing",
]
[[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]] [[package]]
name = "typenum" name = "typenum"
version = "1.16.0" version = "1.16.0"
@ -1820,6 +1910,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]] [[package]]
name = "value-bag" name = "value-bag"
version = "1.4.0" version = "1.4.0"

View file

@ -8,3 +8,6 @@ edition = "2021"
[dependencies] [dependencies]
tokio = { version = "1.28.2", features = ["full"] } tokio = { version = "1.28.2", features = ["full"] }
backend = { path = "./backend" } backend = { path = "./backend" }
tracing-subscriber = "0.3.17"
tracing = "0.1.37"
once_cell = "1.17.2"

86
backend/Cargo.lock generated
View file

@ -56,17 +56,6 @@ dependencies = [
"opaque-debug", "opaque-debug",
] ]
[[package]]
name = "ahash"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
dependencies = [
"cfg-if 1.0.0",
"once_cell",
"version_check",
]
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.5" version = "0.1.5"
@ -82,14 +71,6 @@ version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
[[package]]
name = "anymap"
version = "0.1.0"
source = "git+https://github.com/CompeyDev/signals-rs.git?rev=8a650a1#8a650a19813fce0dbada0e6238b9cfe7cd4660c5"
dependencies = [
"hashbrown",
]
[[package]] [[package]]
name = "arrayref" name = "arrayref"
version = "0.3.7" version = "0.3.7"
@ -321,7 +302,6 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
name = "backend" name = "backend"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anymap",
"framework", "framework",
"rand 0.8.5", "rand 0.8.5",
"serde", "serde",
@ -647,10 +627,11 @@ dependencies = [
name = "framework" name = "framework"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anymap",
"colored", "colored",
"serde", "serde",
"tide", "tide",
"tide-tracing",
"tracing",
] ]
[[package]] [[package]]
@ -774,15 +755,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash",
]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.19" version = "0.1.19"
@ -1579,6 +1551,18 @@ dependencies = [
"serde_json", "serde_json",
] ]
[[package]]
name = "tide-tracing"
version = "0.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "500f567f8c4d65210e6a7c9978661cc7ad6be1dc97e32c3e88bf8f0f0599c23d"
dependencies = [
"async-trait",
"tide",
"tracing",
"tracing-futures",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.45" version = "0.1.45"
@ -1643,6 +1627,48 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tracing"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if 1.0.0",
"pin-project-lite 0.2.9",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.18",
]
[[package]]
name = "tracing-core"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
dependencies = [
"once_cell",
]
[[package]]
name = "tracing-futures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
dependencies = [
"pin-project",
"tracing",
]
[[package]] [[package]]
name = "typenum" name = "typenum"
version = "1.16.0" version = "1.16.0"

View file

@ -8,7 +8,6 @@ edition = "2021"
[dependencies] [dependencies]
framework = { path = "../framework" } framework = { path = "../framework" }
tide = "0.16.0" tide = "0.16.0"
anymap = { git = "https://github.com/CompeyDev/signals-rs.git", rev = "8a650a1" }
serde_json = "1.0.96" serde_json = "1.0.96"
serde = { version = "1.0.163", features = ["derive"] } serde = { version = "1.0.163", features = ["derive"] }
rand = "0.8.5" rand = "0.8.5"

85
framework/Cargo.lock generated
View file

@ -56,17 +56,6 @@ dependencies = [
"opaque-debug", "opaque-debug",
] ]
[[package]]
name = "ahash"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
dependencies = [
"cfg-if 1.0.0",
"once_cell",
"version_check",
]
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.5" version = "0.1.5"
@ -82,14 +71,6 @@ version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
[[package]]
name = "anymap"
version = "0.1.0"
source = "git+https://github.com/CompeyDev/signals-rs.git?rev=8a650a1#8a650a19813fce0dbada0e6238b9cfe7cd4660c5"
dependencies = [
"hashbrown",
]
[[package]] [[package]]
name = "arrayref" name = "arrayref"
version = "0.3.7" version = "0.3.7"
@ -635,10 +616,11 @@ dependencies = [
name = "framework" name = "framework"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anymap",
"colored", "colored",
"serde", "serde",
"tide", "tide",
"tide-tracing",
"tracing",
] ]
[[package]] [[package]]
@ -762,15 +744,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash",
]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.19" version = "0.1.19"
@ -1567,6 +1540,18 @@ dependencies = [
"serde_json", "serde_json",
] ]
[[package]]
name = "tide-tracing"
version = "0.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "500f567f8c4d65210e6a7c9978661cc7ad6be1dc97e32c3e88bf8f0f0599c23d"
dependencies = [
"async-trait",
"tide",
"tracing",
"tracing-futures",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.45" version = "0.1.45"
@ -1631,6 +1616,48 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tracing"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if 1.0.0",
"pin-project-lite 0.2.9",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.18",
]
[[package]]
name = "tracing-core"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
dependencies = [
"once_cell",
]
[[package]]
name = "tracing-futures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
dependencies = [
"pin-project",
"tracing",
]
[[package]] [[package]]
name = "typenum" name = "typenum"
version = "1.16.0" version = "1.16.0"

View file

@ -9,4 +9,5 @@ edition = "2021"
tide = "0.16.0" tide = "0.16.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
colored = "2.0.0" colored = "2.0.0"
anymap = { git = "https://github.com/CompeyDev/signals-rs.git", rev = "8a650a1" } tracing = "0.1.37"
tide-tracing = "0.0.12"

View file

@ -3,6 +3,7 @@
use colored::Colorize; use colored::Colorize;
use std::{collections::HashMap, net::SocketAddr}; use std::{collections::HashMap, net::SocketAddr};
use tide::{Endpoint, Result}; use tide::{Endpoint, Result};
use tide_tracing::TraceMiddleware;
pub enum ReqType { pub enum ReqType {
GET, GET,
@ -26,7 +27,7 @@ pub struct Server {
impl Server { impl Server {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
instance: tide::new(), instance: (&*tide::new().with(TraceMiddleware::new())).to_owned(),
} }
} }
@ -38,9 +39,9 @@ impl Server {
ReqType::POST => route_addr.post(handler), ReqType::POST => route_addr.post(handler),
}; };
println!( tracing::info!(
"{} :: added route {} to routes collection", target: "framework",
"[framework]".bold(), "added route {} to routes collection",
route.blue().underline() route.blue().underline()
); );
} }
@ -51,9 +52,9 @@ impl Server {
.listen(SocketAddr::from(([127, 0, 0, 1], port))) .listen(SocketAddr::from(([127, 0, 0, 1], port)))
.await .await
.and_then(|entry| { .and_then(|entry| {
println!( tracing::info!(
"{} :: {} service listening at port {}", target: "framework",
"[framework]".bold(), "{} service listening at port {}",
scope.green(), scope.green(),
port.to_string().yellow().bold() port.to_string().yellow().bold()
); );
@ -71,9 +72,9 @@ pub async fn setup_server(
let mut server = Server::new(); let mut server = Server::new();
if let Some(routes_map) = opts.bulk_routes { if let Some(routes_map) = opts.bulk_routes {
println!( tracing::info!(
"{} :: setting up server...", target: "framework::bootstrapper",
"[framework_bootstrapper]".bold() "setting up server...",
); );
for (route, handler) in routes_map { for (route, handler) in routes_map {
@ -83,7 +84,14 @@ pub async fn setup_server(
"GET" => ReqType::GET, "GET" => ReqType::GET,
"POST" => ReqType::POST, "POST" => ReqType::POST,
&_ => panic!("framework::setup_serer::bulk_routes -> invalid request method type"), &_ => {
tracing::info!(
target: "framework::bootstrapper",
"invalid route method type",
);
std::process::exit(1);
}
}; };
let route = meta[1]; let route = meta[1];

View file

@ -1,11 +1,27 @@
use once_cell::unsync::Lazy;
use tracing::Level;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
let tracing_level: Lazy<Level> = Lazy::new(|| {
if cfg!(debug_assertions) {
Level::TRACE
} else {
Level::INFO
}
});
tracing_subscriber::fmt()
.with_max_level((&*tracing_level).to_owned())
.init();
let backend_service = match backend::init().await { let backend_service = match backend::init().await {
Ok(server) => server, Ok(server) => server,
Err(err) => panic!( Err(err) => {
"[backend] :: error `{}` occurred while initializing", tracing::error!(target: "backend_service", "error `{}` occurred while initializing", err.to_string());
err.to_string()
), std::process::exit(1);
}
}; };
backend_service backend_service