diff --git a/.gitignore b/.gitignore index 6cb0886..21946af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.idea/ /**/.DS_Store +/tmp/ diff --git a/smart-house-web/Cargo.toml b/smart-house-web/Cargo.toml index 72360fd..bfe32f6 100644 --- a/smart-house-web/Cargo.toml +++ b/smart-house-web/Cargo.toml @@ -1,6 +1,5 @@ -[package] -name = "smart-house-web" -version = "0.1.0" -edition = "2024" +[workspace] +resolver = "3" +members = ["backend"] -[dependencies] +[workspace.dependencies] diff --git a/smart-house-web/backend/Cargo.toml b/smart-house-web/backend/Cargo.toml new file mode 100644 index 0000000..50d15ae --- /dev/null +++ b/smart-house-web/backend/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "backend" +version = "0.1.0" +edition = "2024" + +[dependencies] +axum = "0.8.9" +tracing = "0.1.44" +tracing-subscriber = "0.3.23" diff --git a/smart-house-web/backend/src/lib.rs b/smart-house-web/backend/src/lib.rs new file mode 100644 index 0000000..fba8d83 --- /dev/null +++ b/smart-house-web/backend/src/lib.rs @@ -0,0 +1,16 @@ +pub fn init_logger() { + use tracing_subscriber::{Layer, layer::SubscriberExt, util::SubscriberInitExt}; + + let layer = tracing_subscriber::fmt::layer() + .with_thread_names(true) + .with_file(false) + .with_line_number(false) + .compact() + .boxed(); + if let Err(e) = tracing_subscriber::registry().with(vec![layer]).try_init() { + eprintln!("Logger initialization failed: {:?}", e); + std::process::exit(1); + } else { + tracing::trace!("Logger succesfully initialized"); + } +} diff --git a/smart-house-web/backend/src/main.rs b/smart-house-web/backend/src/main.rs new file mode 100644 index 0000000..339cd95 --- /dev/null +++ b/smart-house-web/backend/src/main.rs @@ -0,0 +1,6 @@ +use backend::init_logger; + +fn main() { + init_logger(); + println!("Hello, world!"); +} diff --git a/smart-house-web/src/main.rs b/smart-house-web/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/smart-house-web/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -}