Trading card city builder game?

add tracing subscriber and tracing http

eldridge.cam fd22b772 3973887f

verified
+141 -1
+2
.env.example
··· 1 + RUST_LOG=info 2 + 1 3 DATABASE_URL="postgres://postgres:postgres@localhost:5432/cartography" 2 4 SHADOW_DATABASE_URL="postgres://postgres:postgres@localhost:5432/shadow" 3 5 ROOT_DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres"
+129
Cargo.lock
··· 3 3 version = 4 4 4 5 5 [[package]] 6 + name = "aho-corasick" 7 + version = "1.1.4" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" 10 + dependencies = [ 11 + "memchr", 12 + ] 13 + 14 + [[package]] 6 15 name = "allocator-api2" 7 16 version = "0.2.21" 8 17 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 156 165 "time", 157 166 "tokio", 158 167 "tokio-stream", 168 + "tower-http", 159 169 "tracing", 170 + "tracing-subscriber", 160 171 "utoipa", 161 172 "utoipa-scalar", 162 173 "uuid", ··· 929 940 checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" 930 941 931 942 [[package]] 943 + name = "matchers" 944 + version = "0.2.0" 945 + source = "registry+https://github.com/rust-lang/crates.io-index" 946 + checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" 947 + dependencies = [ 948 + "regex-automata", 949 + ] 950 + 951 + [[package]] 932 952 name = "matchit" 933 953 version = "0.8.4" 934 954 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 964 984 dependencies = [ 965 985 "libc", 966 986 "wasi", 987 + "windows-sys 0.61.2", 988 + ] 989 + 990 + [[package]] 991 + name = "nu-ansi-term" 992 + version = "0.50.3" 993 + source = "registry+https://github.com/rust-lang/crates.io-index" 994 + checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" 995 + dependencies = [ 967 996 "windows-sys 0.61.2", 968 997 ] 969 998 ··· 1240 1269 ] 1241 1270 1242 1271 [[package]] 1272 + name = "regex-automata" 1273 + version = "0.4.14" 1274 + source = "registry+https://github.com/rust-lang/crates.io-index" 1275 + checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" 1276 + dependencies = [ 1277 + "aho-corasick", 1278 + "memchr", 1279 + "regex-syntax", 1280 + ] 1281 + 1282 + [[package]] 1283 + name = "regex-syntax" 1284 + version = "0.8.9" 1285 + source = "registry+https://github.com/rust-lang/crates.io-index" 1286 + checksum = "a96887878f22d7bad8a3b6dc5b7440e0ada9a245242924394987b21cf2210a4c" 1287 + 1288 + [[package]] 1243 1289 name = "rmp" 1244 1290 version = "0.8.15" 1245 1291 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1397 1443 "cfg-if", 1398 1444 "cpufeatures", 1399 1445 "digest", 1446 + ] 1447 + 1448 + [[package]] 1449 + name = "sharded-slab" 1450 + version = "0.1.7" 1451 + source = "registry+https://github.com/rust-lang/crates.io-index" 1452 + checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" 1453 + dependencies = [ 1454 + "lazy_static", 1400 1455 ] 1401 1456 1402 1457 [[package]] ··· 1737 1792 ] 1738 1793 1739 1794 [[package]] 1795 + name = "thread_local" 1796 + version = "1.1.9" 1797 + source = "registry+https://github.com/rust-lang/crates.io-index" 1798 + checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" 1799 + dependencies = [ 1800 + "cfg-if", 1801 + ] 1802 + 1803 + [[package]] 1740 1804 name = "time" 1741 1805 version = "0.3.47" 1742 1806 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1873 1937 ] 1874 1938 1875 1939 [[package]] 1940 + name = "tower-http" 1941 + version = "0.6.8" 1942 + source = "registry+https://github.com/rust-lang/crates.io-index" 1943 + checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" 1944 + dependencies = [ 1945 + "bitflags", 1946 + "bytes", 1947 + "http", 1948 + "http-body", 1949 + "pin-project-lite", 1950 + "tower-layer", 1951 + "tower-service", 1952 + "tracing", 1953 + ] 1954 + 1955 + [[package]] 1876 1956 name = "tower-layer" 1877 1957 version = "0.3.3" 1878 1958 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1914 1994 checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" 1915 1995 dependencies = [ 1916 1996 "once_cell", 1997 + "valuable", 1998 + ] 1999 + 2000 + [[package]] 2001 + name = "tracing-log" 2002 + version = "0.2.0" 2003 + source = "registry+https://github.com/rust-lang/crates.io-index" 2004 + checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" 2005 + dependencies = [ 2006 + "log", 2007 + "once_cell", 2008 + "tracing-core", 2009 + ] 2010 + 2011 + [[package]] 2012 + name = "tracing-serde" 2013 + version = "0.2.0" 2014 + source = "registry+https://github.com/rust-lang/crates.io-index" 2015 + checksum = "704b1aeb7be0d0a84fc9828cae51dab5970fee5088f83d1dd7ee6f6246fc6ff1" 2016 + dependencies = [ 2017 + "serde", 2018 + "tracing-core", 2019 + ] 2020 + 2021 + [[package]] 2022 + name = "tracing-subscriber" 2023 + version = "0.3.22" 2024 + source = "registry+https://github.com/rust-lang/crates.io-index" 2025 + checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" 2026 + dependencies = [ 2027 + "matchers", 2028 + "nu-ansi-term", 2029 + "once_cell", 2030 + "regex-automata", 2031 + "serde", 2032 + "serde_json", 2033 + "sharded-slab", 2034 + "smallvec", 2035 + "thread_local", 2036 + "tracing", 2037 + "tracing-core", 2038 + "tracing-log", 2039 + "tracing-serde", 1917 2040 ] 1918 2041 1919 2042 [[package]] ··· 2047 2170 "serde_core", 2048 2171 "wasm-bindgen", 2049 2172 ] 2173 + 2174 + [[package]] 2175 + name = "valuable" 2176 + version = "0.1.1" 2177 + source = "registry+https://github.com/rust-lang/crates.io-index" 2178 + checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" 2050 2179 2051 2180 [[package]] 2052 2181 name = "vcpkg"
+2
Cargo.toml
··· 25 25 time = { version = "0.3.47", features = ["serde", "serde-human-readable"] } 26 26 tokio = { version = "1.49.0", features = ["macros", "rt-multi-thread"] } 27 27 tokio-stream = { version = "0.1.18", features = ["sync"] } 28 + tower-http = { version = "0.6.8", features = ["trace"] } 28 29 tracing = "0.1.44" 30 + tracing-subscriber = { version = "0.3.22", features = ["env-filter", "json"] } 29 31 utoipa = { version = "5.4.0", features = ["time"] } 30 32 utoipa-scalar = { version = "0.3.0" } 31 33 uuid = { version = "1.20.0", features = ["serde", "v7"] }
+8 -1
src/main.rs
··· 5 5 mod dto; 6 6 7 7 use kameo::actor::Spawn as _; 8 + use tracing_subscriber::prelude::*; 8 9 use utoipa::OpenApi as _; 9 10 10 11 #[derive(utoipa::OpenApi)] ··· 20 21 21 22 #[tokio::main] 22 23 async fn main() -> anyhow::Result<()> { 24 + tracing_subscriber::registry() 25 + .with(tracing_subscriber::EnvFilter::from_default_env()) 26 + .with(tracing_subscriber::fmt::layer().pretty()) 27 + .init(); 28 + 23 29 let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL is required"); 24 30 let host: std::net::IpAddr = std::env::var("HOST") 25 31 .as_deref() ··· 62 68 )), 63 69 ) 64 70 .layer(axum::Extension(bus)) 65 - .layer(axum::Extension(pool)); 71 + .layer(axum::Extension(pool)) 72 + .layer(tower_http::trace::TraceLayer::new_for_http()); 66 73 let listener = tokio::net::TcpListener::bind((host, port)).await?; 67 74 axum::serve(listener, app).await?; 68 75 Ok(())