Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cargo-shuttle): don't override user provided RUST_LOG on local run #1930

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 15 additions & 20 deletions cargo-shuttle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,20 @@ impl Shuttle {
run_args.port,
);

let mut envs = vec![
("SHUTTLE_BETA", "true".to_owned()),
("SHUTTLE_PROJECT_ID", "proj_LOCAL".to_owned()),
("SHUTTLE_PROJECT_NAME", project_name),
("SHUTTLE_ENV", Environment::Local.to_string()),
("SHUTTLE_RUNTIME_IP", ip.to_string()),
("SHUTTLE_RUNTIME_PORT", run_args.port.to_string()),
("SHUTTLE_API", format!("http://127.0.0.1:{}", api_port)),
];
jonaro00 marked this conversation as resolved.
Show resolved Hide resolved
// Use a nice debugging tracing level if user does not provide their own
if debug && std::env::var("RUST_LOG").is_err() {
envs.push(("RUST_LOG", "info,shuttle=trace,reqwest=debug".to_owned()));
}

info!(
path = %runtime_executable.display(),
"Spawning runtime process",
Expand All @@ -2163,26 +2177,7 @@ impl Shuttle {
dunce::canonicalize(runtime_executable).context("canonicalize path of executable")?,
)
.current_dir(&service.workspace_path)
.envs([
("SHUTTLE_BETA", "true"),
("SHUTTLE_PROJECT_ID", "proj_LOCAL"),
("SHUTTLE_PROJECT_NAME", project_name.as_str()),
("SHUTTLE_ENV", Environment::Local.to_string().as_str()),
("SHUTTLE_RUNTIME_IP", ip.to_string().as_str()),
("SHUTTLE_RUNTIME_PORT", run_args.port.to_string().as_str()),
(
"SHUTTLE_API",
format!("http://127.0.0.1:{}", api_port).as_str(),
),
(
"RUST_LOG",
if debug {
"info,shuttle=trace,reqwest=debug"
} else {
"info"
},
),
])
.envs(envs)
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
.kill_on_drop(true)
Expand Down
8 changes: 7 additions & 1 deletion runtime/src/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ pub async fn start(loader: impl Loader + Send + 'static, runner: impl Runner + S
// let user override RUST_LOG in local run if they want to
EnvFilter::try_from_default_env()
// otherwise use our default
.or_else(|_| EnvFilter::try_new("info,shuttle=trace"))
.or_else(|_| {
EnvFilter::try_new(if args.beta {
"info"
} else {
"info,shuttle=trace"
})
})
.unwrap(),
jonaro00 marked this conversation as resolved.
Show resolved Hide resolved
)
.init();
Expand Down