Skip to content

Commit d5d48bc

Browse files
authored
feat(fortuna): json format on prod (#2806)
1 parent 53df858 commit d5d48bc

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

apps/fortuna/Cargo.lock

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "7.6.4"
3+
version = "7.6.5"
44
edition = "2021"
55

66
[lib]
@@ -32,7 +32,7 @@ sha3 = "0.10.8"
3232
tokio = { version = "1.33.0", features = ["full"] }
3333
tower-http = { version = "0.4.0", features = ["cors"] }
3434
tracing = { version = "0.1.37", features = ["log"] }
35-
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
35+
tracing-subscriber = { version = "0.3.17", features = ["env-filter", "json"] }
3636
utoipa = { version = "3.4.0", features = ["axum_extras"] }
3737
utoipa-swagger-ui = { version = "3.1.4", features = ["axum"] }
3838
once_cell = "1.18.0"

apps/fortuna/src/main.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ use {
1717
#[tracing::instrument]
1818
async fn main() -> Result<()> {
1919
// Initialize a Tracing Subscriber
20-
tracing::subscriber::set_global_default(
21-
tracing_subscriber::fmt()
22-
.compact()
23-
.with_file(false)
24-
.with_line_number(true)
25-
.with_thread_ids(true)
26-
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
27-
.with_ansi(std::io::stderr().is_terminal())
28-
.finish(),
29-
)?;
20+
let fmt_builder = tracing_subscriber::fmt()
21+
.with_file(false)
22+
.with_line_number(true)
23+
.with_thread_ids(true)
24+
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
25+
.with_ansi(std::io::stderr().is_terminal());
26+
if std::io::stderr().is_terminal() {
27+
tracing::subscriber::set_global_default(fmt_builder.compact().finish())?;
28+
} else {
29+
tracing::subscriber::set_global_default(fmt_builder.json().finish())?;
30+
}
3031

3132
match config::Options::parse() {
3233
config::Options::GetRequest(opts) => command::get_request(&opts).await,

0 commit comments

Comments
 (0)