Skip to content

Commit 6014978

Browse files
committed
Migrate from log to tracing
1 parent b56341d commit 6014978

File tree

4 files changed

+98
-55
lines changed

4 files changed

+98
-55
lines changed

ui/Cargo.lock

Lines changed: 82 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ fork-bomb-prevention = []
1212
async-trait = "0.1.52"
1313
axum = { version = "0.6", features = ["headers", "ws"] }
1414
dotenv = "0.15.0"
15-
env_logger = "0.10.0"
1615
futures = "0.3.21"
1716
lazy_static = "1.0.0"
18-
log = "0.4.0"
1917
octocrab = "0.18"
2018
openssl-probe = "0.1.2"
2119
petgraph = "0.6.0"
@@ -30,3 +28,5 @@ strum = { version = "0.24.0", features = ["derive"] }
3028
tempfile = "3"
3129
tokio = { version = "1.9", features = ["macros", "time", "process", "rt-multi-thread"] }
3230
tower-http = { version = "0.3", features = ["cors", "fs", "set-header", "trace"] }
31+
tracing = "0.1.37"
32+
tracing-subscriber = "0.3.16"

ui/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::{
99
path::{Path, PathBuf},
1010
sync::Arc,
1111
};
12+
use tracing::{error, info, warn};
1213

1314
const DEFAULT_ADDRESS: &str = "127.0.0.1";
1415
const DEFAULT_PORT: u16 = 5000;
@@ -25,9 +26,8 @@ fn main() {
2526
let _ = dotenv::dotenv();
2627
openssl_probe::init_ssl_cert_env_vars();
2728

28-
// Enable info-level logging by default. env_logger's default is error only.
29-
let env_logger_config = env_logger::Env::default().default_filter_or("info");
30-
env_logger::Builder::from_env(env_logger_config).init();
29+
// Info-level logging is enabled by default.
30+
tracing_subscriber::fmt::init();
3131

3232
let config = Config::from_env();
3333
server_axum::serve(config);
@@ -66,9 +66,9 @@ impl Config {
6666

6767
let index_html = root.join("index.html");
6868
if index_html.exists() {
69-
log::info!("Serving playground frontend from {}", root.display());
69+
info!("Serving playground frontend from {}", root.display());
7070
} else {
71-
log::error!(
71+
error!(
7272
"Playground ui does not exist at {}\n\
7373
Playground will not work until `yarn run build` has been run or {PLAYGROUND_UI_ROOT} has been fixed",
7474
index_html.display(),
@@ -84,7 +84,7 @@ impl Config {
8484

8585
let gh_token = env::var(PLAYGROUND_GITHUB_TOKEN).ok();
8686
if gh_token.is_none() {
87-
log::warn!("Environment variable {} is not set, so reading and writing GitHub gists will not work", PLAYGROUND_GITHUB_TOKEN);
87+
warn!("Environment variable {} is not set, so reading and writing GitHub gists will not work", PLAYGROUND_GITHUB_TOKEN);
8888
}
8989

9090
let metrics_token = env::var("PLAYGROUND_METRICS_TOKEN").ok();

ui/src/sandbox.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::{
1212
};
1313
use tempfile::TempDir;
1414
use tokio::{fs, process::Command, time};
15+
use tracing::debug;
1516

1617
const DOCKER_PROCESS_TIMEOUT_SOFT: Duration = Duration::from_secs(10);
1718
const DOCKER_PROCESS_TIMEOUT_HARD: Duration = Duration::from_secs(12);
@@ -495,7 +496,7 @@ impl Sandbox {
495496
.await
496497
.context(UnableToSetSourcePermissionsSnafu)?;
497498

498-
log::debug!(
499+
debug!(
499500
"Wrote {} bytes of source to {}",
500501
code.len(),
501502
self.input_file.display()
@@ -518,7 +519,7 @@ impl Sandbox {
518519

519520
cmd.arg(&channel.container_name()).args(&execution_cmd);
520521

521-
log::debug!("Compilation command is {:?}", cmd);
522+
debug!("Compilation command is {:?}", cmd);
522523

523524
cmd
524525
}
@@ -537,7 +538,7 @@ impl Sandbox {
537538

538539
cmd.arg(&channel.container_name()).args(&execution_cmd);
539540

540-
log::debug!("Execution command is {:?}", cmd);
541+
debug!("Execution command is {:?}", cmd);
541542

542543
cmd
543544
}
@@ -551,7 +552,7 @@ impl Sandbox {
551552

552553
cmd.arg("rustfmt").args(&["cargo", "fmt"]);
553554

554-
log::debug!("Formatting command is {:?}", cmd);
555+
debug!("Formatting command is {:?}", cmd);
555556

556557
cmd
557558
}
@@ -564,7 +565,7 @@ impl Sandbox {
564565

565566
cmd.arg("clippy").args(&["cargo", "clippy"]);
566567

567-
log::debug!("Clippy command is {:?}", cmd);
568+
debug!("Clippy command is {:?}", cmd);
568569

569570
cmd
570571
}
@@ -575,7 +576,7 @@ impl Sandbox {
575576

576577
cmd.arg("miri").args(&["cargo", "miri-playground"]);
577578

578-
log::debug!("Miri command is {:?}", cmd);
579+
debug!("Miri command is {:?}", cmd);
579580

580581
cmd
581582
}
@@ -591,7 +592,7 @@ impl Sandbox {
591592
"-Zunpretty=expanded",
592593
]);
593594

594-
log::debug!("Macro expansion command is {:?}", cmd);
595+
debug!("Macro expansion command is {:?}", cmd);
595596

596597
cmd
597598
}

0 commit comments

Comments
 (0)