From 4581c7e5b745f54d9cec4f6a80bb19d2e44c56d3 Mon Sep 17 00:00:00 2001 From: Alexander Baranov Date: Wed, 6 May 2026 14:59:55 +0300 Subject: [PATCH] =?UTF-8?q?smart-house-web:=20=D0=B2=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit smart-house-web: в работе --- .gitignore | 1 + smart-house-web/Cargo.toml | 9 ++++----- smart-house-web/backend/Cargo.toml | 9 +++++++++ smart-house-web/backend/src/lib.rs | 16 ++++++++++++++++ smart-house-web/backend/src/main.rs | 6 ++++++ smart-house-web/src/main.rs | 3 --- 6 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 smart-house-web/backend/Cargo.toml create mode 100644 smart-house-web/backend/src/lib.rs create mode 100644 smart-house-web/backend/src/main.rs delete mode 100644 smart-house-web/src/main.rs 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!"); -}