Logging setup

This commit is contained in:
2025-11-29 00:09:47 +01:00
parent 4c6e0142ca
commit a3e6563912
3 changed files with 57 additions and 2 deletions

View File

@@ -1,12 +1,13 @@
[package] [package]
name = "rustymine-daemon" name = "rustymine-daemon"
version = "0.1.0" version = "0.0.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
anyhow = "1.0.100" anyhow = "1.0.100"
argon2 = "0.5.3" argon2 = "0.5.3"
axum = "0.8.7" axum = "0.8.7"
chrono = "0.4.42"
lazy_static = "1.5.0" lazy_static = "1.5.0"
password-hash = "0.5.0" password-hash = "0.5.0"
rand_core = { version = "0.6", features = ["getrandom"] } rand_core = { version = "0.6", features = ["getrandom"] }
@@ -19,3 +20,6 @@ tower-http = { version = "0.6.7", features = ["cors"] }
tracing = { version = "0.1.43", features = ["max_level_debug"] } tracing = { version = "0.1.43", features = ["max_level_debug"] }
tracing-subscriber = "0.3.22" tracing-subscriber = "0.3.22"
validator = { version = "0.20.0", features = ["derive"] } validator = { version = "0.20.0", features = ["derive"] }
[build-dependencies]
chrono = "0.4.42"

25
src/backend/build.rs Normal file
View File

@@ -0,0 +1,25 @@
use chrono::Utc;
use std::process::Command;
fn main() {
let build_date = Utc::now().to_rfc3339();
let git_hash = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string())
.unwrap_or_else(|_| "unknown".into());
let git_dirty = Command::new("git")
.args(["diff-index", "--quiet", "HEAD", "--"])
.status()
.map(|status| if status.success() { "" } else { "-dirty" })
.unwrap_or("");
println!("cargo:rustc-env=BUILD_DATE={}", build_date);
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
println!("cargo:rustc-env=GIT_SUFFIX={}", git_dirty);
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/refs/");
}

View File

@@ -2,10 +2,36 @@ use std::sync::Arc;
use anyhow::{Ok, Result}; use anyhow::{Ok, Result};
use rustymine_daemon::{router, state::AppState}; use rustymine_daemon::{router, state::AppState};
use tracing::Level; use tracing::{Level, debug, error, info, warn};
pub const APP_NAME: &str = env!("CARGO_PKG_NAME");
pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const BUILD_DATE: &str = env!("BUILD_DATE");
pub const GIT_HASH: &str = env!("GIT_HASH");
pub const GIT_SUFFIX: &str = env!("GIT_SUFFIX");
pub const ASCII_LOGO: &str = "
██████╗ ██╗ ██╗███████╗████████╗██╗ ██╗███╗ ███╗██╗███╗ ██╗███████╗
██╔══██╗██║ ██║██╔════╝╚══██╔══╝╚██╗ ██╔╝████╗ ████║██║████╗ ██║██╔════╝
██████╔╝██║ ██║███████╗ ██║ ╚████╔╝ ██╔████╔██║██║██╔██╗ ██║█████╗
██╔══██╗██║ ██║╚════██║ ██║ ╚██╔╝ ██║╚██╔╝██║██║██║╚██╗██║██╔══╝
██║ ██║╚██████╔╝███████║ ██║ ██║ ██║ ╚═╝ ██║██║██║ ╚████║███████╗
╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚══════╝";
pub const BUILD_MODE: &str = if cfg!(debug_assertions) {
"development"
} else {
"release"
};
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {
println!("{}", ASCII_LOGO);
println!("\nStarting {} v{}-{}", APP_NAME, APP_VERSION, BUILD_MODE);
println!("Git revision: {}{}", GIT_HASH, GIT_SUFFIX);
println!("Built on: {}\n", BUILD_DATE);
let subscriber = tracing_subscriber::fmt() let subscriber = tracing_subscriber::fmt()
.with_max_level(Level::DEBUG) .with_max_level(Level::DEBUG)
.finish(); .finish();