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

Unified the log level configuration behavior #386

Merged
merged 1 commit into from
Oct 18, 2022
Merged
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
11 changes: 5 additions & 6 deletions ballista/executor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ async fn main() -> Result<()> {
let grpc_port = opt.bind_grpc_port;
let log_dir = opt.log_dir;
let print_thread_info = opt.print_thread_info;

let scheduler_name = format!("executor_{}_{}", bind_host, port);

let rust_log = env::var(EnvFilter::DEFAULT_ENV);
let log_filter = EnvFilter::new(rust_log.unwrap_or(special_mod_log_level));
// File layer
if let Some(log_dir) = log_dir {
let log_file = tracing_appender::rolling::daily(log_dir, &scheduler_name);
Expand All @@ -104,18 +105,16 @@ async fn main() -> Result<()> {
.with_thread_names(print_thread_info)
.with_thread_ids(print_thread_info)
.with_writer(log_file)
.with_env_filter(special_mod_log_level)
.with_env_filter(log_filter)
.init();
} else {
//Console layer
let rust_log = env::var(EnvFilter::DEFAULT_ENV);
let std_filter = EnvFilter::new(rust_log.unwrap_or_else(|_| "INFO".to_string()));
// Console layer
tracing_subscriber::fmt()
.with_ansi(true)
.with_thread_names(print_thread_info)
.with_thread_ids(print_thread_info)
.with_writer(io::stdout)
.with_env_filter(std_filter)
.with_env_filter(log_filter)
.init();
}

Expand Down
10 changes: 5 additions & 5 deletions ballista/scheduler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ async fn main() -> Result<()> {
format!("scheduler_{}_{}_{}", namespace, external_host, port);
let scheduler_name = format!("{}:{}", external_host, port);

let rust_log = env::var(EnvFilter::DEFAULT_ENV);
let log_filter = EnvFilter::new(rust_log.unwrap_or(special_mod_log_level));
// File layer
if let Some(log_dir) = log_dir {
let log_file = tracing_appender::rolling::daily(log_dir, &log_file_name_prefix);
Expand All @@ -180,18 +182,16 @@ async fn main() -> Result<()> {
.with_thread_names(print_thread_info)
.with_thread_ids(print_thread_info)
.with_writer(log_file)
.with_env_filter(special_mod_log_level)
.with_env_filter(log_filter)
.init();
} else {
//Console layer
let rust_log = env::var(EnvFilter::DEFAULT_ENV);
let std_filter = EnvFilter::new(rust_log.unwrap_or_else(|_| "INFO".to_string()));
// Console layer
tracing_subscriber::fmt()
.with_ansi(true)
.with_thread_names(print_thread_info)
.with_thread_ids(print_thread_info)
.with_writer(io::stdout)
.with_env_filter(std_filter)
.with_env_filter(log_filter)
.init();
}

Expand Down