feat: Log version string during startup
This commit is contained in:
21
Cargo.lock
generated
21
Cargo.lock
generated
@@ -97,6 +97,7 @@ dependencies = [
|
||||
"axum",
|
||||
"config",
|
||||
"dotenvy",
|
||||
"git-version",
|
||||
"google_home",
|
||||
"hostname",
|
||||
"mlua",
|
||||
@@ -647,6 +648,26 @@ version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
|
||||
[[package]]
|
||||
name = "git-version"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19"
|
||||
dependencies = [
|
||||
"git-version-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "git-version-macro"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.106",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "google_home"
|
||||
version = "0.1.0"
|
||||
|
||||
@@ -74,6 +74,7 @@ config = { version = "0.15.15", default-features = false, features = [
|
||||
"toml",
|
||||
] }
|
||||
dotenvy = { workspace = true }
|
||||
git-version = "0.3.9"
|
||||
google_home = { workspace = true }
|
||||
hostname = { workspace = true }
|
||||
mlua = { workspace = true }
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#![feature(iter_intersperse)]
|
||||
mod config;
|
||||
mod secret;
|
||||
mod version;
|
||||
mod web;
|
||||
|
||||
use std::net::SocketAddr;
|
||||
@@ -27,6 +28,7 @@ use tracing::{debug, error, info, warn};
|
||||
use web::{ApiError, User};
|
||||
|
||||
use crate::secret::EnvironmentSecretFile;
|
||||
use crate::version::VERSION;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct AppState {
|
||||
@@ -76,6 +78,8 @@ async fn app() -> anyhow::Result<()> {
|
||||
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
info!(version = VERSION, "automation_rs");
|
||||
|
||||
let config: Config = ::config::Config::builder()
|
||||
.add_source(
|
||||
File::with_name(&format!("{}.toml", std::env!("CARGO_PKG_NAME"))).required(false),
|
||||
@@ -91,8 +95,6 @@ async fn app() -> anyhow::Result<()> {
|
||||
.try_deserialize()
|
||||
.unwrap();
|
||||
|
||||
info!("Starting automation_rs...");
|
||||
|
||||
// Setup the device handler
|
||||
let device_manager = DeviceManager::new().await;
|
||||
|
||||
|
||||
11
src/version.rs
Normal file
11
src/version.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
pub const VERSION: &str = get_version();
|
||||
|
||||
const fn get_version() -> &'static str {
|
||||
if let Some(version) = std::option_env!("RELEASE_VERSION")
|
||||
&& !version.is_empty()
|
||||
{
|
||||
version
|
||||
} else {
|
||||
git_version::git_version!(fallback = "unknown")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user